Friday, January 31, 2014

Approach Of object-oriented in PHP for Login system- read more @i-visionblog

The world is about the defining classes with data & functions where they can be accessed by real world objects.My last post on PHP login system-Easy Login System is simple way of loging inside a web connecting MySQL,So let us see about approach on Object oriented programming in PHP. Object oriented leads to manage your codes by implementing function and data seperately which interacts with the real world.This post enables you to understand in deeper about usages of classes and object start up.

Uses of Object-Oriented:

1)It let's the developers to manage their codes efficiently and more over they can update their codes if there is need
2)They could manage the data thats's used in the program and prevent the duplication of data flow inside the program
3)Object oriented approach gives you clear map about the working of the system.

How Easily we could code it ?

SQL statement :
this enables you to create a Table in Database for maintaing and handling Data for users.I had mentioned few fields for demo.

  `username` varchar(150) NOT NULL,
  `password` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
INSERT INTO `users` (`id`, `username`, `password`) VALUES
(1, 's.shivasurya', '13IT102');

So let us create a Class for our manage functions and data members efficiently.


class login_user
    var $username;
    var $pwd;
    var $database;
    var $tablename;
    var $connection;
    var $random_key;
    var $error_message;

function GetErrorMessage()
            return '';
        $errormsg = nl2br(htmlentities($this->error_message));
        return $errormsg;
function HandleError($err)
        $this->error_message .= $err."\r\n";
    function HandleDBError($err)
        $this->HandleError($err."\r\n mysqlerror:".mysql_error());
function DBinitialize($host,$uname,$pwd,$database,$tablename)
        $this->db_host  = $host;
        $this->username = $uname;
        $this->pwd  = $pwd;
        $this->database  = $database;
        $this->tablename = $tablename;
   function SetRandomKey($key)
        $this->random_key = $key;
    function Login()
            $this->HandleError("Username is empty!");
            return false;
            $this->HandleError("Password is empty!");
            return false;
        $username = trim($_POST['username']);
        $password = trim($_POST['password']);
        if(!isset($_SESSION)){ session_start(); }
            return false;
        $_SESSION[$this->GetLoginSessionVar()] = $username;
        return true;
    function CheckLogin()
         if(!isset($_SESSION)){ session_start(); }

         $sessionvar = $this->GetLoginSessionVar();
            return false;
         return true;
    function GetSelfScript()
        return htmlentities($_SERVER['PHP_SELF']);
    function SafeDisplay($value_name)
        return htmlentities($_POST[$value_name]);
    function urlredirection($url)
        header("Location: $url");
    function GetLoginSessionVar()
        $retvar = md5($this->random_key);
        $retvar = 'usr_'.substr($retvar,0,10);
        return $retvar;
    function query_db($username,$password)
            $this->HandleError("Database login failed!");
            return false;
        $username = $this->SanitizeForSQL($username);
        $qry = "Select * from $this->tablename where username='$username' and password='$password'";
        $result = mysql_query($qry,$this->connection);
        if(!$result || mysql_num_rows($result) <= 0)
            $this->HandleError("Error logging in. The username or password does not match");
            return false;
        $row = mysql_fetch_assoc($result);
        $_SESSION['name_of_user']  = $row['username'];
       return true;
function LogOut()
        $sessionvar = $this->GetLoginSessionVar();
    function databaselogincheck()

        $this->connection = mysql_connect($this->db_host,$this->username,$this->pwd);

            $this->HandleDBError("Database Login failed! Please make sure that the DB login credentials provided are correct");
            return false;
        if(!mysql_select_db($this->database, $this->connection))
            $this->HandleDBError('Failed to select database: '.$this->database.' Please make sure that the database name provided is correct');
            return false;
        if(!mysql_query("SET NAMES 'UTF8'",$this->connection))
            $this->HandleDBError('Error setting utf8 encoding');
            return false;
        return true;
    function SanitizeForSQL($str)
        if( function_exists( "mysql_real_escape_string" ) )
              $ret_str = mysql_real_escape_string( $str );
              $ret_str = addslashes( $str );
        return $ret_str;
    function Sanitize($str,$remove_nl=true)
        $str = $this->StripSlashes($str);

            $injections = array('/(\n+)/i',
            $str = preg_replace($injections,'',$str);

        return $str;
    function StripSlashes($str)
            $str = stripslashes($str);
        return $str;

So,I have declared data as username,password,database,tablename,connection,random key & Error message.i have connected database using a function and each attempt while accessing the function tries to create a connection and manages connection that performs the function.

Error fun( ) :
this function is used to throw the error message to the user in case of error occurance such as Login failure,Database connection failure, and validation of the input fields of the users.

Login fun( ):
This function enables you to verify the users had already logined in the particular web browser and manage to logout if the session doesnt exist in the browser.

Query fun() :
This enables to query the Database and provides the result to the user whether it may be success or failure one.I have queried the database for username and password verification and for further implementation of sessions.

SanitizeforSQL & strip slashes & self scripting fun( ) :
I have additionally added those function for verifying the users input values and further they are stripped by removing slashes and checking your vulnerability in the input values.I have mentioned the top vulnerability of PHP in my last posts.

urlredirection ( ):
This function enables the users to redirect the page.this is mainly used in the script to redirect to home page once Your credentials and everything is correct.

GetLoginSessionVar() :
This function is mainly implemented for setting session in login with the help of randomkey ( ) funtion which generates the session to implement.I have encrypted the PHPSESSID also for well privacy experience.Session is the important concept in programming because all data is dependent on session,be cautious in determining the session.

Now,It's time to connect with Database.
Let us pass the Credentials and all the regarding data's through the function call statements and creating new instance Object and maintain the data.


$login_user = new login_user();
                      /*database name*/'tce',
                      /*table name*/'users');

here we are passing the arguments for function to be executed.


here I have implemented function url redirection with input as url and checking the login function.

if(!$login_user->CheckLogin() )
echo "welcome,".$_SESSION['name_of_user'];

Logout Fun ( ) enables to destroy the object to destroy and destroy the session naturally to bring the user to stop using the site.

I have called Check login ( ) fun, Error message fun ( ) , Selfscript fun ( ) , url redirection ( ) inorder to get a successful login.
{ $login_user->urlredirection("home.php");
}  ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "">
<html xmlns="" xml:lang="en-US" lang="en-US">
      <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
      <title>mech tce</title>
<link rel="shortcut icon" href=".\S.gif" type="image/x-icon">
      <link rel="STYLESHEET" type="text/css" href="style.css">
<body style="background-color:#E7E7E7">
<div id='login_user' align="middle" style="margin-top:80px;">
<form id='login' action='<?php echo $login_user->GetSelfScript(); ?>' method='post' accept-charset='UTF-8'>
<fieldset style="background-color:#d7d7d7" >

<input type='hidden' name='submitted' id='submitted' value='1'/>
<div class='container' >
<?php if($login_user->GetErrorMessage())
{ ?>
<div class='error'><b><?php echo $login_user->GetErrorMessage(); ?></b></div>
 <?php }  ?>
    <label for='username' >Username*:</label><br/>
    <input type='text' placeholder='username here...' name='username' id='username' value='<?php echo $login_user->SafeDisplay('username') ?>' maxlength="50" /><br/>
<div class='container'>
    <label for='password'>Password*:</label><br/>
    <input type='password' name='password' id='password' maxlength="50" placeholder='password here...'/><br/>
  </div><div class='container'>
<input type='submit' name='Submit' value='Login' />
<div class='short_explanation'>*Required Fields</div><br/>

I'm leaving the style sheet defining in Your side just i had given class name at each tag you can define it on your own.

Thats it.This can successfully create Login System for Your site and manage the functions and code efficient for later updates.Feel free to pointing out my Bugs and share.

Monday, January 20, 2014

Working with masonry.js for aligning images like pintrest- @i-visionblog

Working with masonry.js for aligning images like pintrest & Aligning images using CSS is little bit a tough job as attractively like Facebook Search gallery, Pintrest posts with attractive way of showing images and updates.This masonry.js will work finely for image gallery with images of different sizes ,this would create and manage spaces efficiently and users would surely love this gallery made of masonry.js.It can be easily applied with minimum efforts and make efficient designs.Have a look at the design below.

Download Script files from here -Download

How simple we could code it ?

let us assume a div tag with class and child div containing images like this maintain the image we are giving constant width as 300px and gallery size as width 1300px.
html code:
<div id="gallery" style="width:1300px;"> <!--- your gallery---- !>
<div class="gallerychild"><img src="path/to/your/first image" width="300" /></div>
<div class="gallerychild"><img src="path/to/your/second image" width="300" /></div>
<div class="gallerychild"><img src="path/to/your/third image" width="300" /></div>
<div class="gallerychild"><img src="path/to/your/fourth image" width="300" /></div>

now let us make the gallery look and allign neatly as pintrest gallery.applying jquery.masonry.min.js with respective arguments as options.

<script src="./jquery.js"></script>
<script src="./jquery.masonry.min.js"></script>
    var $container = $('#gallery');
       $container.imagesLoaded( function(){
        itemSelector : '.gallerychild'

let us little CSS to our Image Gallery.

border: 1px solid #69F;
margin: 10px;
box-shadow: 0px 0.1px 0px 2px rgba(0, 0, 0, 0.3),  0px 5px 5px 0px rgba(0, 0, 0, 0.6); 
       height: auto; float:left;

this will create a simple gallery with various size of image.this post will give you iniative only and for more options you must visit masonry.js official website for documentations and further versions.
feel free to comment below!

Wednesday, January 15, 2014

working with Heroku with PHP applications - learnmore with i-visionblog @s.shivasurya

I found Heroku gives an excellent opportunity to create and Host apps for free to certain extent.they support many programming languages and has numerous databases to try for free to some extent.It works on based on cloud computing and never let you down while using now we could try a simple PHP application running through windows platform using GIT bash.

Just create a login by sign up option using your E-mail Id.then you will be getting a link to register with heroku with password.


then users are allowed to download the Toolbelt for managing your apps locally and for uploading it to the cloud storage. click here to download
  • Windows users would be downloading heroku.exe and run the exe file and you should get a desktop icon. 
  • Ubuntu/Debian users run the command in your terminal to download with appropriate permissions.

just run your sh.exe file to do our desired operations.


+ The first time you're running the sh.exe you must provide the login details.just type the bold commands and press enter key.
$ heroku login
Enter your heroku credentials.
E-mail: (you must enter the valid mail id )
password(typing will be hidden):(your heroku password here.)
after successful login you must get like this screenshot.
+ now we are going to create App in Heroku.
$ heroku create <name of your app>
after successfully creating app check out the screenshot.

copy the highlighted address and you may use it later.
C:\Users\username>git clone [email protected]:your_highlighted_address.git -o heroku
+ now we are going to clone the app and create the folder named as application.

finally we have created the app and screen shot gives below.

+ now manually Copy your PHP files C:\users\<username>\<yourappname>
and now we are going to change directory by using cd command.
$ cd <appname>
the resultant screenshot below.

+ now we are going to update the heroku master and getting ready for uploading the files to cloud.
$ git add -A
this enables to update the repository.

update statement:
$ git commit -am "Added one file"
this enables you to update the current folder and the resultant would be like this.

+ now we are going to upload the file to the cloud to online usage for others.
$ git push heroku master
this enable you to upload to the main server cloud and available online usage.resultant would be,
thus this would end with success message with address to access.

+ now it is time to run your application on browser.
$ heroku open
thus this will open your web address of your hosted application.

so whenever you're updating files follow from add -A command.

NOTE: using heroku you could use SSL https secure connection for free for a certain extent.
You could run Facebook Application by adding https simply and calling inside Iframe Facebook Application.

feel free to comment below.

Sunday, January 12, 2014

Increase Internal memory of android phone - read more with @i-visionblog

The whole world is now moving towards Mobile OS such as Android,I-OS,Blackberry OS and so on.This becomes a scope for many Applications to develop and run in the specific OS.And this makes the users to experience the worth of Android or any mobile OS phones equivalent to the desktop computers.Thus RAM is specifically needed to run apps on the specific platform and experience the users flexibility and reduce the inconvenience.Human Desires are uncontrollable,Thus We always in search for more options and applying in this topic you could increase your internal memory of your android phone and experience more app usages.


1) A Rooted Android Phone.
2) Link2SD application - Download
3)Mini Tool Partition Application for your PC or Laptop - Download
4) SD card above 2 GB


1)Download the Mini Tool Partition for your PC with correct configuration and install it.
2)Connect your SD card with PC via. Open mini tool partion on your pc.
3)Right Click on name of Your SD card and click delete.
4)Now right click again and click the Create option.
5)Give the file system as FAT32 and select create as primary.give the name of the label and drive letter of sdcard.Give the partition size which is used as a external storage of your choice.
6)Now right click on unallocated space and click on create and click on yes.give create as primary and select file system as ext2 or ext3 or ext4 whichever that suits your phone.Give the name of the partition label and select all remaining unallocated space for partition.This partition is used as internal memory in your phone.

7)Now click on ok and then click on apply option on upper left corner.The partitioning will begin.
8)Wait till the process is completed.After completion put your sd card in your phone
9)Open link2sd in your phone and select the extension ext2 or ext4.
 10)Allow superuser request.
11)when it displays mount scipt created reboot your phone.
12)Open link2sd in your phone.Go to settings select autolink and go to autolink settings  and select
Link application file,linkdalvik-cache file,link library files.
go back to settings and under general options select relink lib files at boot,fast scroll.
13)Now select install location and select external.

That’s it now whenever you install an app it will be installed in the second partition of the sd card rather than in the sd card or internal memory.Therefore the second partition will serve as additional internal memory.Suppose to install the app in sd card or internal memory deselect autolink option and select install location as automatic.


feel free to comment below.

Increase Internal memory With Chandeesh Babu,TCE.

view my profile on fb: Chandeesh Babu

Mail Id :  [email protected]

Thiyagarajar College Of Engineering.

Saturday, January 11, 2014

Enabling Replies in Facebook Comments for Profiles- read more @i-visionblog

We are living in Profile world which we represent in the form of Photo updates and status updates where others could comments,likes,+1's.We are addicted towards Likes,Comments,Replies in Facebook.Increasing the heat i have written an simple article to enable Replies For your profile in Facebook.Actually Facebook Allows Legal option to have only replies for Facebook Pages to experience more comment activities,Why can't we upgrade and maintain Facebook replies for comments for our profile too.Just have look at the procedure!

How Does Replies On Facebook Helps?

Facebook Introduces Reply option in Addition to comments to make the users more sophisticated and experience till the core of commenting the status,Photos and whatever else in Facebook.Actually they are officially used in Facebook Pages for admins to reply to their Followers.

How to Enable?

1)Login to Your Facebook Account in Google Chrome Browser.
2)open new tab type
3)Right click and select Inspect Elements.
4)Click on the Gear Menu On the Bottom Most right corner (Just Above Your Clock)

5)In that Click the OverRide Option And Click on the Check Box override option.

6)Enable override Geolocations And enter the following appropriately Lat:-41.289996 & lon:174.781555 and just press enter key. now  Check In.(please don't post it ,just leave it )

7)now open your Desktop site normally and post anything.

8)try to comment them You would be recieving an Reply option to that. Have fun!

How to disable ?

1)Just Go to the same Place Geolocation ,make Latitude & Longitude text box empty and uncheck all boxes.

2)Click CheckIn the same page.
3)this Return backs to normal state once again with comments alone in every posts.!

we are not responsible for any other changes in your accounts in facebook.try it in your own risk as we dont know the effect of the enabling replies in facebook profile.try it on your own profile at own risk.our blog is not responsible on anyway!

Monday, January 06, 2014

I-OS on Samsung Galaxy Y - read more with @chandeesh.Android

Installing I-OS using FLASH DDLK2 STOCK FIRMWARE  on Samsung Galaxy Y. I-OS is closed source software used in Apple devices.where now we could just use a Sample of I-OS in our Samsung Galaxy Y.

why we are targeting Samsung galaxy Y for such testing ?

Samsung galaxy Y is most stable & Basic Android phone that universally peoples uses it.Many Stock ROM's are only available for Samsung Galaxy Y .Due to it's stableness Many developers test their settings using this phone.

What is DDLK2 Firmware?

DDLK2 firmware is an very stable firmware that can run many ROMs without any bugs  such as Samsung logo stuck while booting,recovery problems such as ‘cant mount system’,’cant mount cache’.It also works with many kernels.


A ROOTED ANDROID PHONE is very much essential for doing this task and experiencing I-OS 7 on your Samsung galaxy Y.
then, Download as a whole zip.

1) CSC_S5360_ODDLK1.tar.md5               
2) MODEM_S5360_DDLK1.tar.md5   
3) PDA_S5360_DDLK2.tar.md5 

Procedures to Unbrick your Galaxy Y phone:

Download Odin3-v3.07 program here ( and extract it to your PC. Look for the “Odin3 v3.07.exe” and Run in your PC.
Enable usb debugging in your phone.Downloadusb drivers for your phone and install it in your phone.

Open odin1.85 in your pc.Connect the phone to your pc via usb.Go to the download mode in your phone by pressing (volume down+homebutton+power key).

Now the ID:COM port will turn to yellow this means that your phone is successfully connected to pc.

Now click on PDA and select PDA_S5360_DDLK2.tar.md5 from the extracted zip file.
Similarly click on CSC and select CSC_S5360_ODDLK1.tar.md5
Click on PHONE and select MODEM_S5360_DDLK1.tar.md5
Now ensure that except Auto reboot and F,rest time no other box is checked.

Click on start and wait.


Download ios7 custom ROM( for Samsung galaxy y
Download and for galaxy.
Place these files in the root of the sd card.
Now reboot your phone in recovery mode by pressing volumeup+homebutton+power key.
Select apply update from sd card and select you are in clockworkmod
Now go to mounts and storage and mount all the things ie mount system,mountdata,mountsdcard,mount cache.
Now go back and select install zip from sd card and select file
Now go to advanced and select reboot recovery
Go to mounts and storage and format the following things format system,formatdata,format cache
Now go to mounts and storage and mount all the things ie mount system,mountdata,mountsdcard,mount cache
Now go back and select install zip from sd card and select choose zip from sd card and select
Flashing may take some time.After installation wipe data and factory reset and go to advanced and wipe dalvik cache
Reboot system now.On booting apple logo will appear
Select ilauncher as default.
Experience ios7 on your Samsung galaxy y.


feel free to comment below.

Enjoy I-OS in Samsung Phone With Chandeesh Babu,TCE.

view my profile on fb: Chandeesh Babu

Mail Id :  [email protected]

Thiyagarajar College Of Engineering.

Wednesday, January 01, 2014

Title bar Alert like Facebook Chat messages - read more @i-visionblog

We would have experienced this when we chat in Facebook,the chat box just blinks or Title bar just blinks.have you ever wondered how does they work.yes, they work just because of Javascript .This makes us easy visible of tabs and noticing it while working on any other tab in the browser.
Title bar Alert like Facebook Chat messages - read more @i-visionblog
Add caption

here is the Javascript download link : Download  | Demo

View the Demo Source Code to Implement the tile Bar Alert in your app correspondingly!

How Do they work ?

when you receive a response from the database new entry through Ajax or Node.js sockets may be anyother,the response is passed through this javascript functions and then the javascript start doing it process of title alert in the browser.And when the user clicks on it then the function comes to the end and goes on! this is how many things are happens in the advanced sites like Facebook ,Google etc.

Why Do they Implement this ?

This Tends to be visible for the users and to pull attraction towards the tab! were nowadays many uses notify tone with these to make users to experience more comfortable.While the users are working more than a tab in the system,this may surely help them to interpret them and find difference.

Procedure :

see the highlighted code below! this may be useful wherever you want and implementating this!

<script src=""></script>
 <script src="../jquery.titlealert.js"></script>
 <script type="text/javascript" >
  $( document ).ready(function() {
type: "GET",
url: "data.php",
success: function(data){
}); //end of ajax 
}); //end of click event
}); //end of document


Other Options :


Title Alert works with jQuery 1.3 and 1.4. It's tested in Firefox, Chrome, Internet Explorer >= 6 and Safari.

Please Report for Bugs/Corrections/Errors/Help/hugs to [email protected] or chat with me in Facebook/G+ and connect with me in Twitter.Share is Care.