Browser Event Restricions|

(Using Scripts)
  • Right Click
  • Back Button
  • Total Calculation
  • PDO Read
// Right Click and Ctrl + ('a', 'n', 'c', 'x', 'j' , 'w', 'U') Restriction

<!DOCTYPE html>
<html>
<body class="menubar-hoverable header-fixed my_class"  onkeypress="return disableCtrlKeyCombination(event);" onkeydown="return disableCtrlKeyCombination(event);">    

<script language="JavaScript">

//F12 disable code
    document.onkeypress = function (event) {
        event = (event || window.event);
        if (event.keyCode == 123) {
           //alert('No F-12');
            return false;
        }
    }
    document.onmousedown = function (event) {
        event = (event || window.event);
        if (event.keyCode == 123) {
            //alert('No F-keys');
            return false;
        }
    }
document.onkeydown = function (event) {
        event = (event || window.event);
        if (event.keyCode == 123) {
            //alert('No F-keys');
            return false;
        }
    }

//Disable right click script 
//visit http://www.rainbow.arch.scriptmania.com/scripts/ 
var message="Sorry, right-click has been disabled"; 
/////////////////////////////////// 
function clickIE() {if (document.all) {(message);return false;}} 
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) { 
if (e.which==2||e.which==3) {(message);return false;}}} 
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;} 
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;} 
document.oncontextmenu=new Function("return false") 
// 
function disableCtrlKeyCombination(e)
{
//list all CTRL + key combinations you want to disable
var forbiddenKeys = new Array('a', 'n', 'c', 'x', 'j' , 'w', 'U');
var key;
var isCtrl;
if(window.event)
{
key = window.event.keyCode;     //IE
if(window.event.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}
else
{
key = e.which;     //firefox
if(e.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}
//if ctrl is pressed check if other key is in forbidenKeys array
if(isCtrl)
{
for(i=0; i<forbiddenKeys.length; i++)
{
//case-insensitive comparation
if(forbiddenKeys[i].toLowerCase() == String.fromCharCode(key).toLowerCase())
{
//alert('Key combination CTRL + '+String.fromCharCode(key) +' has been disabled.');
return false;
}
}
}
return true;
}
</script>    
</body>
</html>

// Back Button Restriction

<script>
history.pushState(null,null,location.href);
window.onpopstate = function(){
history.go(1);
}
</script>

// Total Calculation

<script>
function gtito()
{
    var gtot=0;
    $(".spareparts_totalamount").each(function(){
        if($(this).val()!=""){
            gtot+=parseInt($(this).val());
    }
    });
    $("#gtot").val(gtot);
    $("#gtoty").show();    
}
</script>

// Read (Fetching)

<?php
include('db.php');
//Multiple Row Fetching
$query = "SELECT * FROM users";
$exe = $conn->prepare($query);
$exe->execute();
$info = $exe->fetchAll(PDO::FETCH_ASSOC);
$array = array();

foreach($info as $info_data)
{
    $first_name = $info_data['first_name'];
}

//Single Row Fetching
$query = "SELECT * FROM users";
$exe = $conn->prepare($query);
$exe->execute();
$info = $exe->fetch(PDO::FETCH_ASSOC);
$array = array();
$first_name = $info['first_name'];
?>