How to Destroy Session When users close the browser tab in php

We can use “onbeforeunload” javascript function 

include this javascript  code in your html named check_browser_tab_close.js

// JavaScript Document
/**
* This javascript file checks for the brower/browser tab action.
* It is based on the file menstioned by Daniel Melo.
* Reference: http://stackoverflow.com/questions/1921941/close-kill-the-session-when-the-browser-or-tab-is-closed     * http://eureka.ykyuen.info/2011/02/22/jquery-javascript-capture-the-browser-or-tab-closed-event/
*/
var validNavigation = false;

function endSession() {
// Browser or broswer tab is closed
// Do some your php function to destroy the session
alert("Your Session is destroy");
}

function wireUpEvents() {
/*
* For a list of events that triggers onbeforeunload on IE
* check http://msdn.microsoft.com/en-us/library/ms536907(VS.85).aspx
*/
window.onbeforeunload = function() {
if (!validNavigation) {
endSession();
}
}

// Attach the event keypress to exclude the F5 refresh
$('document').bind('keypress', function(e) {
if (e.keyCode == 116){
validNavigation = true;
}
});

// Attach the event click for all links in the page
$("a").bind("click", function() {
validNavigation = true;
});

// Attach the event submit for all forms in the page
$("form").bind("submit", function() {
validNavigation = true;
});

// Attach the event click for all inputs in the page
$("input[type=submit]").bind("click", function() {
validNavigation = true;
});

}

// Wire up the events as soon as the DOM tree is ready
$(document).ready(function() {
wireUpEvents();
});

And your HTML file looks like this 

<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="check_browser_tab_close.js"></script>
</head>
<body>
<h1>Hello Guest......</h1>
<a href="http://about.me/yuvrajingale">My Portfolio</a>
</body>
</html>

About Heredoc :

Heredoc is a robust way to create string in PHP with more lines  without using quotations…

Heredoc in php start with <<< this operator

EX.01

<?php

$string = <<<DEMO

This is a EXAMPLE

message with

heredoc.

DEMO;

echo $str

?>

Output:

This is a EXAMPLE message with heredoc.

EX.02

<?php

$name = “Guest”;

$string = <<<DEMO

Hello $name! <br/>

This is a

demo Example2

with heredoc.

DEMO;

echo $string;

?>

Output:

Hello Guest!  This is a demo Example2 with heredoc.

Google+ Sharing Custom button for your app

Share Custom message from your own website using this

Step 1.

<?php $message=”Your Custom message goes Here……..”; ?>

Step 2.

<a href=”https://m.google.com/app/plus/x/?v=compose&content=&lt;?php $message  ?>” onclick=”window.open(‘https://m.google.com/app/plus/x/?v=compose&content=&lt;?php $message  ?>’,’gplusshare’,’width=450,height=300,left=’+(screen.availWidth/2-225)+’,top=’+(screen.availHeight/2-150)+”);return false;”><img src=”http://path.to/plus.png&#8221; alt=”Share on Google+” width=”55″ height=”22″ /></a>

thats it…..

Facebook Custom iFrame Share Button

Share anything on facebook  like link ,custom text – content, video ,image using this code from your website

Step .1

<?php
$title_face=urlencode(‘Title of Your Tab’);
$url_link=urlencode(‘http://www.facebook.com/yourfanpage&#8217;);
$message=urlencode(‘Custom message ……………’);
$image_photo=urlencode(‘http://www.yourajwebs.uphero.com/images/post.jpg&#8217;);
?>

Step .2

<a onClick=”window.open(‘http://www.facebook.com/sharer.php?s=100&amp;p%5Btitle%5D=&lt;?php echo $title_face;?>&amp;p[summary]=<?php echo $message;?>&amp;p[url]=<?php echo $url_link; ?>&amp;&p[images][0]=<?php echo $image_photo;?>’, ‘sharer’, ‘toolbar=0,status=0,width=548,height=325’);” target=”_parent” href=”javascript: void(0)”>
FShare</a>

thats it ….ur share button is ready

Interview Questions For Joomla CMS

Joomla is Content Management System developed in PHP (open source)

Its uses MVC (Model-View-Controller) pattern

Features:

  1. Open Source
  2. Freely Available
  3. Developed in php
  4. MySQL Support which most popular database
  5. Admin And User Panel (Easy to Use)
  6. Released under the G|N|U General Public License 2 (GPL)
  7. Supports All International Languages
  8. Page Caching
  9. RSS Feeds
  10. Printable version of pages
  11. News Flashes
  12. blogs
  13. polls
  14. search
  15. Plugins (Third Party) Supports
  16. Modules Supports (to extend the functionality in Joomla)

What are pathways or breadcrumbs?
If you are on a particular page and to get to that page you had to go through several folders to find that particular page, then that series of links will be your pathway or breadcrumb. For example: Home >> Books >> Pages >> New Page.

How to remove the pathway or breadcrumbs?
If you want to remove your pathway permanently, you have to edit your html (index) file, which will normally look like this:
<div id=”pathway”>
<?php mosPathway(); ?>
</div>.      or you can search “pathway” word you can get it directly

What are section, categories and content items?

Sections and categories allow you to organize your content.

The basic structure is:
Sections => include Categories.
Categories => include content items.

  • Remove the page title from the front page 

    To remove the title from being displayed on the front page of your site, you need to change a parameter setting in the front page component.

    * First log into the administrative back end.
    * On the top menu click “Menu”->”mainmenu”
    * Click “Home”.
    * On the right side of the screen in the parameters section, locate the “Page Title” parameter       that is next to the radio buttons “Show” and “Hide”.
    * Click the “Hide” radio button.
    * Click the “Save” button to make your change permanent.