#SignMyTL – A Complete Microblog using PHP & MySQL (Facebook Like Timeline)

#Website:

A website is a location to the internet that maintains one or more webpages.

#Microblog: 

Microblog is a social media site to which a user makes short, frequent posts.

#SignMyTL

#SignMyTL is a digital autobiograph for one who wants to create log of the key activities of their daily life on the Web. The key feature to this application is that user can share blog post, upload images, youtube videos, facebook timline layout, share immediate comments, smiley support, infinite scroll of website.

Why #SignMyTL?
1. I want my private TimLine public.
2. I want to make a history of my life.
3. I want to connect with my friends differently.
4. I am what my friends talk about me.
5. I want to say something silently.
6. Social Networks are getting fake day by day.
7. I want to be true to myself.

How to get #SignMyTL?

Click here to download #SignMyTL
Click here to view Live Demo

How to install #SignMyTL?

1. Extract and upload SignMyTL directory using ftp client software.

Directory Structure :

SignMyTL 1.0

  • assets
    images
    javascripts
    smileys
    stylesheets
  • imagecache
  • includes
  • uploads

2. Use signmytl.sql to create database & tables.
3. Modify the database credentials in the SignMyTL/config.php.
4. Access your SignMyTL using http://your.domain.name/SignMyTL.

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

VMware Player unrecoverable error: (vmx)

When I opened my VMware today, following error was displayed:

VMware Player unrecoverable error: (vmx)

Exception 0xc0000006 (disk error while paging) has occurred.

A log file is available in "C:UsersacerDocumentsVirtual MachinesRed Hat Enterprise Linux 6 64-bitvmware.log".

You can request support.

To collect data to submit to VMware technical support, run "vm-support".

We will respond on the basis of your support entitlement.

[dfads params=’groups=-1′]

Solution: Remove the following two files from the VMware installed directory. You can check the installed directory from Player -> Manage -> Virtual Machine Settings -> Options

  1. Red Hat Enterprise Linux 6 64-bit-93cd0331.vmem
  2. Red Hat Enterprise Linux 6 64-bit-93cd0331.vmss

[Source: http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1002347]

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′]

How To scp, ssh and rsync without prompting for password

Following steps would help you to do scp, ssh & rsync without prompting for password:

1. On Host A where you run scp/ssh/rsync command, run the following command: 

$ ssh-keygen -t rsa

This will prompt a passphrase. After pressing enter key it’ll generate a private and a public key. Public key is saved at ~/.ssh/ by default.

2. Transfer id_rsa.pub file to Host B using scp or ftp.

[dfads params=’groups=-1′]

3. On Host B, login as remote user and copy the contents of id_rsa.pub to ~/.ssh/authorized_keys using the following command:

$ cat id_rsa.pub >>~/.ssh/authorized_keys
$ chmod 700 ~/.ssh/authorized_keys

4. Thats’ all, Now you can run scp, ssh and rsync command without prompting for password.

5. Note that ssh by default does not allow root to log in. This has to be explicitly enabled on Host B. This can be done by editing /etc/ssh/sshd_config and changing the option of PermitRootLoginfrom no to yes. Don’t forget to restart sshd so that it reads the modified config file. Do this only if you want to use the root login.

[dfads params=’groups=-1′]

MTNL Broadband Browsing Problem

[dfads params=’groups=-1′]

I am using MTNL Broadband for 1 and a half years. I had never faced Webpage browsing problem since then. I called MTNL Customer Care many times but they fooled me. Problem still not solved.

Then I started searching regarding the problem my own. I googled with the same title as this post. I found that huge number of MTNL Customers facing the same problem.

images

After continuous haunt for the solution I found a blog where the author introduced me about opendns. It was a new topic to me and was not that concerned. I followed the comments on that post I found some dns ips and was told that if updated on your system’s network config Browsing Problem would vanish.

Immediately, I updated my dns configuration. God damn, it worked. Thanks to the auther.

Following are the DNS IPs :

208.67.222.222,

208.67.220.220

[dfads params=’groups=-1′]

Starting web server: apache2(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80

download

$service apache2 restart
[....] Starting web server: apache2(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
failed!

In order to solve the above issue, type following on your console

fuser -k -n tcp 80

[dfads params=’groups=-1′]

How to Recover Files Hidden by Virus in Pen Drive?

[dfads params=’groups=-1′]
 

memory-card

  1. Open Windows Command Prompt in elevated mode (for Windows 8, 7, Vista)
  2. Go to path of pen drive i.e. my case it is F, type f: and hit enter
  3. Type attrib -s -h -r /S /D and hit enter

 

[dfads params=’groups=-1′]