Posts marked with "Posts" in posts

Password Protect folder in AppFog

You won’t know the location of the .htpasswd file in AppFog. Hence you won’t be able to password protect folders in the normal way. To password protect folders in AppFog you should use a different way. You should add the following location of .htpasswd instead of the full location.
If the full location is :

/home/simsu/projects/TestPalace/Blog/Password_Protect/.htpasswd

The Location of .htpasswd in .htaccess deployed in AppFog should be :

../app/Blog/Password_Protect/.htpasswd

If the file is on the root directory, then the location would be :

... [READ MORE]

Password protect folder using HTACCESS

HTACCESS is able to protect folders with passwords. To password protect folders you should mention the location of .htpasswd – a file that contains the username and password to unlock the folder.
First of all create a .htaccess file if doesn’t exists and create a .htpasswd file.
Now Add username and password to the .htpasswd file which you can get from this simple tool.

Add the following text in .htaccess :

AuthName "This folder requires a login"
AuthType Basic
AuthUserFile /home/simsu/projects/TestPalace/Blog/Password_Protect/.htpasswdAuthGroupFile /dev/null
require valid-user

... [READ MORE]

Split Name in PHP and Javascript

If you have a user with a long name and want to short it because it won’t fit into the element that contains the name, you can either do it on the server or the client. In this post I am going to tell you how to accomplish this with PHP and JavaScript.
Suppose We have a user named Paul Steve Panakkal (my cousin). To separate the first name, middle name and last name you can do the following in PHP :

... [READ MORE]

Prevent Directory Listing using HTACCESS

If you don’t want your site users to see your directory listing, you can do a simple trick in .htaccess file.
Here is a screenshot of a directory listing on Apache Server :

Now, to disable directory listing of all types of files, type in the following code in .htaccess :

IndexIgnore *

This will change the directory listing to this :

The empty directory listing looks ugly. To make it beautiful, you can add an index page for all directory listings without adding each index files on each directory. Use the following code on .htaccess for that.

... [READ MORE]

Program to Replace localhost links with website url

If you are working on a project and wants to upload the project to your site, then you have to manually replace all the localhost links with the site url. I created a small Python program that will replace localhost links with your WWW site url.
Here is the Python code :

#!/usr/bin/python
import os
indir = ‘/var/www/mysite‘ #!Folder of your localhost site.
for root, dirs, filenames in os.walk(indir):
 for f in filenames:
  log = open(os.path.join(root, f), ‘r+’)
  f=log.read()  
  n=f.replace("http://localhost", "http://mysite.com")
  log.seek(0)
  log.truncate()
  log.write(n)
  log.close()
print "Successfully Replaced."

... [READ MORE]

Cross Origin Communication – window.postMessage

The Window.postMessage helps to make scripts talk over different domain connections. When you call a function on an external iframe from the parent window, Javascript won’t allow it.
That’s because of the Cross Domain Policy that makes this not possible. But it’s possible since Javascript introduced postMessage function.

Suppose you want to call a function on an cross domain iframe with id monu. Let the function be subins(). Here’s how to do it using postMessage technic.

... [READ MORE]

Loading Bar until page loads completely using Javascript

This tutorial was requested by Sumit. In this tutorial I’m going to tell how to put up a loading screen until the page has loaded completely.

DEMO
Here is the screenshot of loading screen :

The loading bar will fade out when loading is completed.

This code will work for all sites including Blogger Blogs, WordPress Blogs except Dynamic Views Template of **Blogger **(because it uses ajax loading). You can change the image if you want. I have created an image of my own :

... [READ MORE]

Setting Iframe height to its content height using Javascript

While loading an iframe on page the most difficult thing is to set it’s height to the height of the content of the iframe. I looked around the web and got the code. This is pure Javascript, doesn’t contain jQuery or any other libraries. Set these functions :

function getDocHeight(doc) {
    doc = doc || document;
    var body = doc.body, html = doc.documentElement;
    var height = Math.max( body.scrollHeight, body.offsetHeight,
        html.clientHeight, html.scrollHeight, html.offsetHeight );
    return height;
}
function setIframeHeight(id) {
    var ifrm = id;
    var doc = ifrm.contentDocument? ifrm.contentDocument: ifrm.contentWindow.document;
    ifrm.style.visibility = ‘hidden’;
    ifrm.style.height = "10px"; // reset to minimal height in case going from longer to shorter doc
    // some IE versions need a bit added or scrollbar appears
    ifrm.style.height = getDocHeight( doc ) + 4 + "px";
    ifrm.style.visibility = ‘visible’;
}

... [READ MORE]

Create MySQL Injection free Secure Login System in PHP

There were a lot of people who created tutorials to create a PHP Login System. But they were all vulnerable to MySQL Injection. In this post I’m going to demonstrate a login system free of this vulnerability. It is very secure. There are mysqli and PDO in PHP to escape these injections. We are going to use **PDO ( PHP Data Object **).

UPDATE – logSys

There is a new, free, better Advanced Login System which you can check out here.

... [READ MORE]

Better Google Chrome History Page

As you know, Google Chrome‘s Browser History is not efficient. It’s history is not like any other browsers. I think they made the History page in a hurry. If we want to search for a page we visited before, we won’t get it by searching on History page. That’s the main problem.
This problem was solved when a lot of users created an alternate History Page extension on Chrome Webstore.
In this post I’m gonna tell the most used History Alternate Extension. It’s Better History extension. You can download the extension from here.

Deleting:

... [READ MORE]

Follow/Subscribe

Telegram 

Mastodon  Twitter

GitHub GitLab

Subdomains

Demos  Lab

Past

This blog was once on WordPress. Now a static site. See source code on

GitLab