Install SSL Certificate – godaddy

[ Login to Godaddy Sales Account ]
1. Login to your godaddy sales account -> Go to SSL Certificates -> Click on Manage

2. Click on View Status

3. Click on download from Certificate Management Options -> Extract from the zip file (You will get two .crt files)

[ Login to Hosting cPanel ]

4. Login to your hosting cPanel -> Go to Home -> Go to SSL / TLS -> Click on Certificates (crt)

5. Browse and upload crt file (That you downloaded from the Sales, follow point 3)

6. Next you will be followed by the system.

 

[dfads params=’groups=-1′]

How to implement Heatmap on Websites using PHP, MySQL, jQuery and Ajax?

I was assigned a task when an Interviewer interviewed me and that was a Technical question. I was asked to design a system that can gather click data from a webpage and show it later in form of a Heatmap.

[dfads params=’groups=-1′]

This system can be integrated into any website which records visitor clicks on the page. The goal of of this will be to track visitor’s mouse clicks on various elements of the page and later show them accurately in form a Heatmap. The owner should be able to see aggregated click data in form of an overlay on top of his webpage. The areas in the heatmap that are red more clicks compared to the areas that are white.

After googling through the internet I found some resources which were very interesting. I devoted some time and tried to implement a demo. Please follow the following Steps:

1. Client Code : Create a file index.php and include the following code below. This is the page where users make clicks.

[code]
<script type=’text/javascript’ src="js/jquery-lib.js"></script> <!– jQuery library –>
<script type=’text/javascript’ src="js/hm-dev.js"></script> <!– Log JS –>

<title>99-Websites.com Labs</title>
<body>
<div style="text-align:center">
<img src="99-ws-labs.jpg" />
</div>
</body>

[/code]

2. The Ajax Call : Create a JS file named as hm-dev.js. This file is included in the above index.php page. Add the snippet below:

[code]
/*
Author : Dev
Date : 12/06/2015
*/

jQuery(document).ready(function() {
jQuery(document).click(function(e){
//alert(window.location.href.toString().split(window.location.host)[1]+" — "+e.pageX+" — "+e.pageY);
log_click(window.location.href.toString(), e.pageX, e.pageY);
});
var canvas = document.getElementsByTagName(‘canvas’)[0];
canvas.style.display = "none";
});

function log_click(page, x, y){ // log clicks for heatmap
jQuery.ajax({
type: ‘POST’,
url: ‘log_click.php’,
crossDomain: true,
data: "x_coord="+x+"&y_coord="+y+"&page="+page,
dataType: ‘json’,
success: function(responseData, textStatus, jqXHR)
{
if (responseData== 1){
console.log("Click logged: " + x + ", " + y);

}
else{
console.log("Error – click not logged " + x + ", " + y);
}
},
error: function (responseData, textStatus, errorThrown)
{
console.warn(responseData, textStatus, errorThrown);
alert(‘CORS failed – ‘ + textStatus);
}
});
}
[/code]

3. Log the Clicks : Create a PHP file named with log_click.php and add the following snippet.

[code]

<?php
header(‘Access-Control-Allow-Origin: *’);
header(‘Access-Control-Allow-Methods: POST, GET, OPTIONS’);
header(‘Access-Control-Max-Age: 1000’);
header(‘Access-Control-Allow-Headers: Content-Type’);

//echo json_encode(array("your_request_was" => $_POST[‘page’].$_POST[‘x_coord’].$_POST[‘y_coord’]));

include(‘config.php’); //Create config.php file and define $dbuser, $dbpass & $dbname

if(isset($_POST[‘x_coord’])){
$page = htmlentities($_POST[‘page’]);
if($page == "/"){ $page = "/index.php"; }
$xcoord = htmlentities($_POST[‘x_coord’]);
$ycoord = htmlentities($_POST[‘y_coord’]);
$time = date( ‘Y-m-d H:i:s’);

$conn = mysql_connect(‘localhost’, $dbuser, $dbpass);
mysql_select_db($dbname, $conn);
$page = mysql_real_escape_string($page);
$xcoord = mysql_real_escape_string($xcoord);
$ycoord = mysql_real_escape_string($ycoord);

mysql_query("INSERT INTO clicks (timestamp, page, x, y) VALUES (‘$time’, ‘$page’, $xcoord, $ycoord)");
mysql_close($conn);
echo "1";
}
else
{
echo ‘0’;
}

?>

[/code]

4. Create MySQL Table : Create table with following fields:

[code]

CREATE TABLE IF NOT EXISTS `clicks` (
`timestamp` datetime NOT NULL,
`page` varchar(200) NOT NULL,
`x` int(255) NOT NULL,
`y` int(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

[/code]

That’s it, the first part is over. After implementing the above steps you will be able to log clicks on the MySQL Table. The next and the main part is viewing the heat maps.

5. Create the Admin Page : Create PHP page named with admin.php. This page will lists out all the domains on which the client side code is added. When the links are clicked, their respective heatmaps will be displayed below the same page.  Admin Code is listed below:

[code]

<?php
/*
Author : Dev
Date : 12/06/2015
*/
include("config.php");
$con2 = mysql_connect(‘localhost’, $dbuser, $dbpass);
mysql_select_db($dbname, $con2);
$query = "SELECT distinct page FROM `clicks` WHERE 1";
$result = mysql_query($query);
?>
<html>
<head>
<title>Heatmap Admin</title>
<script type=’text/javascript’ src="js/jquery-lib.js"></script>

<script type=’text/javascript’ src="js/heatmap.js"></script>
<script>
jQuery(document).ready(function(){
var heatmapInstance = h337.create({
container: document.querySelector(‘.display’),
radius: 25
});

jQuery(".showcanvas").click(function(){
//location.reload();
//alert(jQuery(this).attr(‘value’));
var timescale = "day";
var page = jQuery(this).attr(‘value’);
//alert(page);
var postData = "timescale="+timescale+"&page="+page;
jQuery.ajax({
type:"POST",
dataType: "json",
data: postData,
beforeSend: function(x) {
if(x && x.overrideMimeType) {
x.overrideMimeType("application/json;charset=UTF-8");
}
}, url: ‘heatmap.php’,
success: function(data) {

if (data.amount > 0){
for (i=0; i<data.amount; i++){
heatmapInstance.addData({
x: data[i].x,
y: data[i].y,
value: 2
});
}
}
}
});

});
});
</script>
</head>
<body >
<div style="width:100%; border:1px solid; black;">
[Click on the Websites below to View their respective HeatMaps]<br>
<ul style="font-size:12px;">
<?php
while($row = mysql_fetch_assoc($result)){
?>
<li><a href="#" class="showcanvas" value="<?=$row["page"]?>"> <?=$row["page"]?></a></li> <br/>

<?php

}
?>
</ul>
</div>
<div class="display" style="width:100%;height:100%;border:1px solid; black;float:right;">
</div>

</body>
</html>

[/code]

The main logic behind the code is the heatmap.js library. In order to understand in detail you can explore the following references:

1. http://www.patrick-wied.at/static/heatmapjs/example-click-heatmap.html

2. http://rossmarks.co.uk/blog/?p=683

3. http://www.d-mueller.de/blog/cross-domain-ajax-guide/

You can view the Demo here: 

1. Client / Users Page : http://99labs.net where you can make some clicks on the webpage.

2. Admin Page : http://dewendra.com.np/labs/hm/admin.php where you can view the Heatmap.

Also, You can download the whole code from here : Download

[dfads params=’groups=-1′]

PS : The client code can be installed into any website and their logs can be maintained on the remote server. If you go through the client side code you can see the ajax code implemented with CORS (Cross Origing Resource Sharing) using jQuery.

Alternatives to NPAPI plugin

After upgrading the earlier versions of Chromium browsers to later versions greater than 42, internet users have started complaints that the JAVA plugins are not supported by chrome. After a bit research, found that chromium browsers have disabled NPAPI plugin-in on their latest versions. The deprecation of NPAPI plug-in caused the JAVA plugins to be blocked in Chrome. 

[dfads params=’groups=-1′]

What is NPAPI plug-in? (Source: Wiki)

Netscape Plugin Application Programming Interface (NPAPI) is a cross-platform plugin architecture used by many web browsers.

It was first developed for Netscape browsers, starting in 1995 with Netscape Navigator 2.0, but was subsequently adopted in Internet Explorer 3 in 1996 and implemented by many other browsers, although some browsers later dropped support.

For stability and security reasons, Google Chrome decided, in 2013, to start phasing out support for NPAPI. As of Chrome version 42, NPAPI is disabled by default and must be re-enabled explicitly. Google intends to remove support entirely in version 45, due in September 2015. 

Alternatives to NPAPI (Source: chromium.org)

With the deprecation of NPAPI, some developers have asked which modern technologies can be used to implement features which in the past would have relied on a platform-specific NPAPI plug-in. In answer to these questions we have composed the following list of common NPAPI use cases and web platform alternatives.

In general, the core standards-based web technologies (HTML/CSS/JS) are suitable for most client software development. If your application requires access to features outside the web sandbox, myriad Chrome Extension and App APIs offer access to OS features.

Video and audio

A common use case for NPAPI plug-ins on the modern web is embedded video and/or audio. A range of modern web technologies exist to facilitate media streaming.  The basic building blocks are WebRTC and media elements:

HTML5 Media Elements:  The HTML5 Specification provides a rich media platform through the <audio> and <video> elements. More complicated use cases can be achieved using the <canvas> element (for example check out the Video FX Chrome Experiment).

WebRTC:  WebRTC was designed for real time communication between peers and the technology can also be used for applications like live streaming media and data. Google’s Chromecast device uses WebRTC to stream HD video between a browser and TV.

Several features on top of these building blocks support more advanced use cases:

Adaptive Streaming

The ability to adapt media streaming to an individual consumer is critical in delivering high-quality content to a large audience. In the past this capability has been provided by technologies such as Silverlight’s smooth streaming and Quicktime’s HTTP live streaming. The Media Source Extensions to the HTML media element provide the capability to adapt a stream to an individual consumer on the modern web. Html5rocks has put together a great example of how to use the Media Source Extensions to implement some of these common use cases.

Video Conferencing

Several of the most popular NPAPI extensions including Facebook Video Chat and Google Talk provide video conferencing functionality within the browser. With the introduction of WebRTC video conferencing is facilitated directly through JavaScript APIs. The Cube Slam Chrome Experiment provides an example of peer to peer video conferencing via WebRTC.

Digital Rights Management

Encrypted Media Extensions give HTML5 video the DRM capabilities that previously would have required the use of a platform specific plug-in. The WebM project has provided a demo which performs video playback using the Encrypted Media Extensions of the video element.  For more information, check out the EME HTML5 Rocks article.

Closed Captioning

WebVTT and the <track> element (a child element of <video>) enable web developers to add timed-text captioning capabilities to their HTML apps.

Communicating with native applications

Try the Native Messaging API for Chrome Apps and Extensions.

Games & 3D

Native Client (NaCL) provides a rich environment for cross-platform game development. Many games have already been ported to or designed for NaCL. A number of examples and detailed tutorials to get started with NaCL are available on the NaCL development site. The WebGL specification provides a high-performance platform for hardware-accelerated 3D graphics in the browser. Chrome experiments has an entire category dedicated to examples and demos of various WebGL use cases.

Security

Some services have relied on NPAPI-based security techniques.  We recommend switching to TLS or, soon, Web Crypto.

Hardware access

In the past it has often been necessary to write platform specific plug-ins to access system hardware such as webcams, microphones, USB devices, and bluetooth. Direct access to local media streams such as webcams and microphones can now be requested directly from the web via the WebRTC Media Capture specification. Chromium also provides an App API for access to USB hardware and another API for accessing Bluetooth devices.

Screen capture

Chrome extensions can perform screen capture or streaming using either Desktop Capture for full screen capture or the Tabs API captureVisibleTab for individual tab content capture. 

[dfads params=’groups=-1′]

Reference:

http://www.chromium.org/developers/npapi-deprecation

http://en.wikipedia.org/wiki/NPAPI

Import large database tables from CSV files using oracle_loader driver in Oracle External Table

After trying various techniques to import csv data to oracle tables, I found this as the simplest and the fastest way to import large databases into oracle tables. This technique uses oracle_loader driver in Oracle External Table. The basic is that external table displays data by reading from a physical file.

[dfads params=’groups=-1′]

Steps:
1. Create a physical directory in one of your drive. Paste your csv data into the same directory.

2. Execute the script below on sqldeveloper.

3. Congratulations, play with your data tables.

[code]
create or replace directory my_data_app as ‘D:my_data_app’;

CREATE TABLE BULK_KYC_UPLOAD_BY_EMPLOYER_AI
( office_id number(11) ,
uan varchar2(12) ,
cur_mid varchar2(25) ,
document_type varchar2(1) ,
document_name varchar2(85) ,
document_no varchar2(25) ,
ifsc_code varchar2(11) ,
employee_name varchar2(100) ,
expiry_date varchar2(50) ,
edu_quali_flag varchar2(1) ,
phy_hand_flag varchar2(1) ,
phy_hand_cat_flag varchar2(1) ,
gender_flag varchar2(1) ,
number_worker_flag varchar2(1) ,
martial_status_flag varchar2(1) ,
establishment_id varchar2(15) ,
scan_document_flag number(11) ,
alredy_veryfied_flag number(11) ,
document_scan_image varchar2(100) ,
dob varchar2(50) ,
doj varchar2(50) ,
doe varchar2(50) ,
father_husband_name varchar2(85) ,
fs_flag varchar2(1) ,
bulk_kyc_tracking_id varchar2(15) ,
text_file_upload_date varchar2(50) ,
online_verification number(1),
ts_online_verification varchar2(50) ,
employer_verification number(1) ,
ts_employer_verification varchar2(50) ,
field_office_verification number(1),
ts_field_office_verification varchar2(50) ,
added_by varchar2(1) ,
missing_detail_source_flag varchar2(1) ,
ts varchar2(50),
duplicate_flag varchar2(2),
duplicate_ts varchar2(50)
)
ORGANIZATION EXTERNAL
(
TYPE ORACLE_LOADER
DEFAULT DIRECTORY my_data_app
ACCESS PARAMETERS
(
RECORDS DELIMITED BY NEWLINE
SKIP 1
LOGFILE my_data_app:’data.log’
BADFILE my_data_app:’data.bad’
DISCARDFILE my_data_app:’data.disc’
fields terminated by ‘,’
OPTIONALLY ENCLOSED BY ‘"’
MISSING FIELD VALUES ARE NULL
(
office_id,
uan ,
cur_mid ,
document_type ,
document_name,
document_no,
ifsc_code,
employee_name,
expiry_date,
edu_quali_flag,
phy_hand_flag,
phy_hand_cat_flag,
gender_flag,
number_worker_flag,
martial_status_flag,
establishment_id,
scan_document_flag,
alredy_veryfied_flag,
document_scan_image,
dob,
doj,
doe,
father_husband_name,
fs_flag,
bulk_kyc_tracking_id,
text_file_upload_date,
online_verification,
ts_online_verification,
employer_verification,
ts_employer_verification,
field_office_verification,
ts_field_office_verification,
added_by,
missing_detail_source_flag,
ts,
duplicate_flag,
duplicate_ts
)
)
LOCATION (my_data_app:’kyc_16012015.csv’)
)reject limit unlimited;

select * from BULK_KYC_UPLOAD_BY_EMPLOYER_AI;

select * from BULK_KYC_UPLOAD_BY_EMPLOYER_AF rownum < 200;

drop table BULK_KYC_UPLOAD_BY_EMPLOYER_AI;

insert into bulk_kyc_upload_by_employer_af select * FROM bulk_kyc_upload_by_employer_ai;
commit;
[/code]

In order to Export large database table into a dump file using oracle_datapump driver in Oracle External Table, Click Here
[dfads params=’groups=-1′]

Export large database table into a dump file using oracle_datapump driver in Oracle External Table

[dfads params=’groups=-1′]

There are various ways to export oracle database tables. Here, I was dealing with large database tables when I was working at one of the india’s biggest government company. I had to import and export crores of tuples from and to csv files.
Following is the simplest example to unload data from huge oracle database to a dump file using oracle_datapump driver in Oracle External Table.

[code]create or replace directory my_data_app as ‘D:my_data_app’;

create table bulk_kyc_xt
ORGANIZATION EXTERNAL
(
TYPE ORACLE_DATAPUMP
DEFAULT DIRECTORY my_data_app
LOCATION (‘bulk_kyc_xt.dmp’)
)
AS SELECT * FROM bulk_kyc_upload_by_employer_af;

select * from bulk_kyc_xt;

drop table bulk_kyc_xt;

[/code]

In order to import oracle table from a csv file using oracle external table, click here.

[dfads params=’groups=-1′]

ORA-24408: could not generate unique server group name

After continuous google for more than 10 hours, I finally came to a conclusion that the problem “ORA-24408: could not generate unique server group name” was not with oracle instanclient or the connection string oci_connect(). The only problem was with the mis-match of the hostnames of the application server defined in /etc/sysconfig/network & /etc/hosts.

[dfads params=’groups=-1′]

After modifying the hostnames in both the file to a single name, the problem was solved.

 $ vi /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=RHEL65
$vi /etc/hosts

$ vi /etc/hosts
#127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
127.0.0.1    RHEL65

$service network restart

The above steps helped me save my valuable time. Thanks to the bloggers.

I hope these information would help you too. Best wishes!

[dfads params=’groups=-1′]

[Source: http://ahmadzainuddinzakaria.blogspot.in/2012/06/warning-ociconnect-functionoci-connect.html]

How do I setup proxy in Red Hat Enterprise Linux to access internet?

To setup the proxy environment variable as a global variable, open /etc/profile file:

# vi /etc/profile

Add the following information:

export http_proxy=http://proxy-server.name.or.ip:3128/

OR

export http_proxy=http://USERNAME:PASSOWRD@proxy-server.mycorp.com:3128/

Save and close the file.

[dfads params=’groups=-1′]

How to take backup and restore openvz (Proxmox Virtual Environment)?

Well, I am not that sound in playing with the tools of openvz but through the assistance of professionals, I came to learn how to take backup of openvz and restore it in another proxmox virtual environment. In order to understand this tutorial, you must have a little knowledge of Linux and its basic commands. The following steps more or less clearifies the process:

[dfads params=’groups=-1′]

 

  1. Login to your proxmox via root.
  2. Check whether there is sufficient space to take backup. Use the command below to check the available space on the system:

    moon:~# df -h

    Filesystem Size Used Avail Use% Mounted on

    /dev/mapper/pve-root 95G 15G 76G 16% /

    tmpfs 16G 0 16G 0% /lib/init/rw

    udev 10M 632K 9.4M 7% /dev

    tmpfs 16G 0 16G 0% /dev/shm

    /dev/mapper/pve-data 723G 272G 452G 38% /var/lib/vz

    /dev/sda1 504M 44M 435M 10% /boot

  3. In order to list out the virtual machines type the following command:

    moon:~# vzlist

    CTID NPROC STATUS IP_ADDR HOSTNAME

    101 67 running 10.10.10.110 hindi-website.example.com

    103 206 running 10.10.10.251 maincopy.example.com

    201 92 running 10.10.10.106 engsecondary.example.com

    240 64 running 10.10.10.108 wsdb-backup.example.com

    242 78 running 10.10.10.107 hi-secondary.example.com

    410 109 running 10.10.10.104 rc.example.com

  4. Note down the CTID for which you are taking the backup. CTID is an identifier which uniquily represents the respective virtual machine.
  5. Follow the command below to take the backup of the virtual machine:

    moon:~# sudo vzdump –dumpdir /var/lib/vz/dump/ 103 –suspend –compress

The above command takes a complete backup of the virtual machine whose CTID is 103 at the location /var/lib/vz/dump/. The backup process will take approximately an hour to complete. In order to confirm the successfull backup change the directory to /var/lib/vz/dump/ and execute the command ls or dir. Two files are generated prefixed by vzdump-openvz-*.

  1. Copy the backup to another proxmox using the following command:

    moon:~# scp vzdump-openvz-103-2014_06_24-17_22_53.tgz root@10.10.10.44:/var/lib/vz/dump/

  2. In order to restore, first of all login to your proxmox via GUI.
  3. Delete the virtual machine if there is insufficient space or make some space to restore the backup.
  4. Now, Login to your proxmox using ssh or putty. Change your directory to /var/lib/vz/dump/ (location of the backup) . Execute the following command:

    earth:~# vzrestore vzdump-openvz-103-2014_06_24-17_22_53.tgz 103

The above command will restore the backup creating a complete new virtual machine. It takes approximately an hour to complete the process.

  1. Login to your proxmox via GUI. A new virtual machine will be visible. Before starting the machine modify the IP Address in order to prevent the IP conflict.
  2. If the macnine contains MySQL binded with the IP then modify the IP from the file /etc/mysql/my.conf

[dfads params=’groups=-1′]

Http Error 0 in Drupal

[dfads params=’groups=-1′]

Http Error 0  is a very common error that occurs in Drupal. There are many reasons behind this error.

htttp-error-0

One of the way to resolve this error is to append the following line in this file : /etc/apache2/mods-available/fcgi.conf

[code]

MaxRequestLen 536870912

[/code]

Increase the number value of the MaxRequestLen until the error stops to continue.

[dfads params=’groups=-1′]

Load Testing on Web Servers using Apache Benchmark

ab

After working on many websites, I found one of my site getting too many traffic bringing down the site. I contacted the technical support who fixed the problem. I had never tested load on any of my site. So, I started studying load testing on web servers. This helped me to understand how many users can be handled by my website so that it can run smoothly.

I found a very light and strong linux tool called Apache Benchmark Tool that can test load on Web Servers. This can benchmark Apache, IIS and other web server with apache benchmarking tool called ab. There are also other open source tools that helps to test load on web servers.

[dfads params=’groups=-1′]

I executed following command on my linux terminal:

[code]

ab -c 1000 -n 1000 -t 60 -k http://ignou.ac.in

[/code]

Option -c : This option says there are 1000 concurrent users logged in on the Web Server.

Option -n : This option sends 1000 requests to the Web Server.

Option -t : This option says users will be logged in for 60 seconds.

Option -k : For Keep Alive On

I logged in to the web server and executed the following command to test the actual load.

[code]

top

[/code]

This command helped to track down the load average, CPU and Memory Utilization of the web server.

[dfads params=’groups=-1′]