Skip to main content


Showing posts from March, 2012

How to Protect Text From Coping with Javascript

Though advanced tools will enable you to copy any text from any web page, but to protect the content from most of the users we can make the copiers life a little painful in the JS way.
To protect text we will disable most of the common methods of the keyboard and mouse.. like…
Rightclick, Ctrl+s + Ctrl+a , Drag and select... Place the below JS in the head section… </strong></p> </p> <p> <p><strong></strong></p> </p> <p> <p><strong> 

</strong></p> </p> <p> <p><strong></strong></p> </p> </blockquote> <blockquote> <p><strong> Now To make it liittle more powerful let’s use Jquery too… Add a Jquery file … Now add the following script in ur head section…. $(function(){       $(document).keydown(function(objEvent) {                if (objEvent.ctrlKey) {  //alert(objEvent.keyCode);                    if (objEvent.keyCode == 65 || objEvent.keyCode =…

How to Protect From Image Being Copied

I must say in the begining that it is almost impossible to stop the images or text being copied, but making it difficult will prevent most of the users to steal content.. In this article I will give a easier but effective way of protecting images with html/css. We will take a very simple way for this… Firstly in a div we will place the image with a given height and width. (Say 200 X 200) Now we will place another transparent image with same height and width and give it a margine of -200. So that it will overlap the actual image. And when the user will try to copy this, they will end up with the transparent gif only… <div style=”float: left;”> <img src=”your-image.jpg” style=”width: 200px;height: 200px;”/> <img src=”the-dummy-image.png” style=”border: 0px solid #000; width: 200px; height: 250px; margin-left: -200px; ” /> </div>

How to Increase Page Download Speed

There are some basic steps you can follow... 1.Minimize the number of HTTP requests in pages. Eliminate all unnecessary items from your page. Try to club small css files in a single one. Use less images in your page. More HTTP requests will in crease your page speed. 2. Optimize Images. Normally images are the heaviest files in a page. Try to optimize the images as much as possible. Use better image editingsoftwares and make them as small as possible in weight. 3. Minify Scripts. Try to minify scripts like JS, CSS, HTML. Jquery has minified versions of all of their versions. Also minify the CSS files. This will increase your page speed pretty good. 4. Compress contents Use server features for GUNZIP the pages. This will compress the pages and deliver it to the user browser much faster. Apache has default plugins for this. 5. Defer Page Loading Try to use ajax or similar technologies to deffer the page load. Load different parts of the page separately through ajax. This will give a much sm…

How to Point Domain to Your Webserver

Just bought a domain name? and having a server else where? Let’s see the basic steps for telling your DNS server to point your web server, when your domain name is fired

If the DNS management is there with your domain name provider, you need to add the A record/ NS record of your server there.
In your hosting server you can create 1 or more than 1 NS records and add them in your domain name account.
In case of shared hostings, you will have ns records already created for you along with a IP address.
For example…
For NS record you will see an ip address
You just need to specify these in your domain name account.
In case of Dedicated hostings if you have the ip address of your server (Normally available only for the dedicated hosting), you can add this ip address as the A record in your domain name account.
If you are hosting your website in amazon EC2 servers, you will get ip addresses named as Elastic IP. There you need to associate the ip address to y…

How to Make PHP Site Faster with APC

The Alternative PHP Cache (APC) is a free open source project of PHP. It gives a very good sollution for code cache of PHP. UsingAPC will considerably boost up the speed of your PHP site. It caches immidiate opcode of PHP and also gives a user cache for storing the application data. Below are the steps for downloading APC and installin it with PHP... Download the APC tar ball ... # wget Unpack it into a directory.. now run the below caoomand ... /opt/lampp/bin/phpize-x.x.x; Here the version of phpize corresponds to the version of PHP you want to install for.
Now run the following commands 
# ./configure --enable-apc --with-apxs --with-php-config=/opt/lampp/bin/php-config-5.0.4 # make # make install
If every thing goes well, edit your php.ini # vi /etc/php.ini and add the below line and save the file. Now restart the apache server... # service httpd restart Now create a .php file with phpinfo() and run it in the browser. If the output shows a s…

How to Detect and Protect Server From Ddos/syn Attack

The below command will show the number of active connections open in your server. Many of the attacks typically work by starting a connection to the server and then not sending any reply making the server wait for it to time out. The number of active connections from the first command is going to vary widely but if you are much above 500 you are probably having problems. If the second command is over 100 you are having trouble with a syn attack. In  syn  attack the main problem is the huge number of open connections. The attackers actually starts a connection to the server but does not send a reply back to the server and thus the server keeps waiting for the reply till timeout. So so many connections are open in a small span of time... We need to check the number of active connections in our server first...issuing the below command # netstat -n | grep :80 |wc -l It is unsafe if it shows above 500... # netstat -n | grep :80 | grep SYN |wc -l Now we need to find out the culprit ip with th…

Why Jquery is The Best Javascript Library

Jquery is the most popular and widely used javascript library. Let’s see why… Any web developer in the world must know this name, Jquery. Though there are several JS libraries in the market, but it is the most popular one.  There are several reasons behind it. I am listing few of them below. Easy to use.Very Light weight.Fast.Well documented.So many helping sites or tutorials through out the net.Better compatibility with almost all browsers. One more thing I would like to highlight. Jquery has also launched a mobile library. It is capable of design very dynamic mobile websites with a few line of codes. These mobile sites perfectly renders in all hand held devices like IOS, Android, Nokia and many more. With a little touch of HTML5 and Jquery mobile, you can build fabulous mobile websites really fast.
Go to the below official link of Jquery mobile… It has some nice demos and way forward to the new comers… Let’s do some good work then…. 

How to Create Your Own Website

As we know that a website is known with it's name. i.e the the website name. So to have a website we need to buy a name for that to denote it. Technically it is called Domain Name. We need to buy it for some finite period of time from any of the Domain name providers. The cost of it will depend on how many years you are buying the domain for.

The it comes to the website. You need to build your website, which the visitors will see on your site. It can be couple of html files or a complex web application.

Now after you build your application, you need to host the application somewhere in a system. For that you need to buy a hosting. You can buy it from several hosting providers in the market.

After you properly run our application in your hosting machine, you need to tell your domain name to point the hosted machine's application whenever that domain name is fired.

For that you need to configure the DNS of the domain you bought. Most of the domain name providers will give you a…

How to Add Ftpuser in Plesk Via Command Line

Firstly assuming that we are already having a ftp user in Plesk. Now fire this command from root user... #id mridul   (Assuming the existing ftp user is mridul) this will give a output similar to below output... # uid=10000(mridul) gid=524(psacln) groups=524(psacln) Now note down the number 10000. We will need it later. Now make encrypted password to use it while creating new ftp user... # perl -e 'print crypt("password", "salt")' Let's assume we are saving the password in variable $pass. We will need it later. this will give a encrypted string for the give password string.... Now issue the below command to add new ftp user  "rock"
# /usr/sbin/useradd -u 10000 -o -d /var/www/vhosts/  -g psacln -s /bin/false rock In this command we are setting the default ftp directory for user rock.  To set the password while creating the user, we can alter the command like below... # /usr/sbin/useradd -u 10000 -o -d /var/www/vhosts/e…

How to Change Passwords of Linux Using PHP

Firstly We will take the username and the new password in a variable... $user='someuser'; $pass='somepass';   Then lets ensure the sed command fires perfectly from php. Taking it's path in a variable... $sed='/bin/sed';  To set the new password we need to encrypt the password fast.... $salt = substr($user, 0, 2); $pass_crypt = crypt($password, $salt); $pass_crypt=str_replace("/","/",$pass_crypt); Lastly we will fire the php command system like below... system($sed." -i 's/".$user.":[a-zA-z0-9/$.]*/".$user.":".$pass_crypt."/g' /etc/shadow",$retval); remember that we need to fire the system command as root. i.e  system("sudo ".$sed." -i 's/".$user.":[a-zA-z0-9/$.]*/".$user.":".$pass_crypt."/g' /etc/shadow",$retval); For this we need to grant apache in sudoers file with nopasswd parameters.  Go to .. /etc/sudoers and add the below line apache ALL=(…

Auto Recovery of Http After Crash or Hang

In very popular and high traffic sites, it is very often to face httpd hangs. In these cases only manual restart is the only solution. I would like to share a script for the solution of this problem…
First lets write a script for checking the system state, if it is alarming, we will fire our recovery script with a mail script attached with it…
Let’s say we are going to keep our script at /usr/local/recover folder and the script name is Issue the below command first
# cd /usr/local
# mkdir recover
# cd recover
# vi
Next paste the below script in the file and save it…
monitor=`cat /proc/loadavg | sed ’s/./ /’ | awk ‘{print $1}’`
if [ $ monitor -gt 10 ]

In the second line we are getting the load average of the server in 5 minuites. If it is greater than 10, we are fireing the script named
Now give this file 755 permission by the below command…
# chmod 777
Now we need to wr…