making web mouse for linux

                       making web mouse for linux 

   Required tools:
   1.php
   2.mysql server
   3.apache2 server with php configured 
   4.xdotool utility command
   5.sql
   6.javascript for ajaxing part
                                             "SQL PART"
Now create a table named "coord" containing properties described below
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| xy    | varchar(10) | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
                                     
                 File :    "INTERFACE <index.html> "
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!---
#: Title: 
#: Date: 
#: Author: "Hitesh Saini" <hs@hiteshs.netai.net>
#: Version: 1.0
#: Description :
#: Options:
*/
-->
<html>
<title></title>
<head>
<style type="text/css">
    button{
        width: 25%;
        height: 25%;
        position: absolute;
    }
    #left{
        left: 39%;
        top: 32%;
    }
    #right{
        left: 60%;
        top: 32%;
    }
    #down{
        left: 50%;
        top:60%;
    }
    #up{
        left: 50%;
    }
</style>
</head>
<body><center>
<div>
    <button id="left">Left</button>
    <button id="right">Right</button>
    <button id="up">Up</button>
    <button id="down">Down</button>
    <button id="push">Click</button>

</div>

</center>
<script>
var x=1366/2,y=740/ 2,url,http;
var diff=15;
document.getElementById("left").addEventListener("touchstart",function(e){
                     x-=diff;
                    if(!x)x=2;
              url='do.php?x='+x+'&y='+y;http=new XMLHttpRequest();http.open("GET",url);http.send();

},false);
document.getElementById("right").addEventListener("touchstart",function(e){
    x+=diff;url='do.php?x='+x+'&y='+y;http=new XMLHttpRequest();http.open("GET",url);http.send();

},false);
document.getElementById("up").addEventListener("touchstart",function(e){
   
    y-=diff;
if(!y)y=2; 
 url='do.php?x='+x+'&y='+y;http=new XMLHttpRequest();http.open("GET",url);http.send();

},false);
document.getElementById("down").addEventListener("touchstart",function(e){
    y+=diff;url='do.php?x='+x+'&y='+y;http=new XMLHttpRequest();http.open("GET",url);http.send();

},false);
document.getElementById("push").addEventListener("touchstart",function(e){
    var c=y+" click 1";
     url='do.php?x='+x+'&y='+c;http=new XMLHttpRequest();http.open("GET",url);http.send();

},false);

</script>
</body>
</html>
                                   

                                   "do.php"
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
/*
#: Title: 
#: Date: 
#: Author: "Hitesh Saini" <hs@hiteshs.netai.net>
#: Version: 1.0
#: Description :
#: Options:
*/
if($_GET['x']&&$_GET['y'])
{
 $x=$_GET['x'];$y=$_GET['y'];
 $conn   = mysql_connect('localhost', 'username', 'password');
   if(! $conn )
   {
      die('Could not connect: ' . mysql_error());
   }
   $xy=$x." ".$y;
   $sql = "UPDATE coord SET xy='$xy'";
   mysql_select_db('dbname');
   $retval = mysql_query( $sql, $conn );
   
   if(! $retval )
   {
      die('Could not enter data: ' . mysql_error());
   }
   
   echo "Entered data successfully\n";
   
   mysql_close($conn);
}
?>

                                   
                                            " start.sh"
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
#: Title: 
#: Date: 
#: Author: "Hitesh Saini" <hs@hiteshs.netai.net>
#: Version: 1.0
#: Description :
#: Options:
while [ true ]
do
 daa=$( php "get.php" )
       set $daa
        xdotool mousemove $1 $2 
        if [ "$3" == "cl" ]
   then
  xdotool mousemove $1 $2 click 1
  php "clido.php" $1 $2  
 fi   
        sleep 0.2
done
                                 
                                   "get.php" 
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
/*
#: Title: 
#: Date: 
#: Author: "Hitesh Saini" <hs@hiteshs.netai.net>
#: Version: 1.0
#: Description :
#: Options:
*/

 $conn   = mysql_connect('localhost', 'username', 'password');
   if(! $conn )
   {
      die('Could not connect: ' . mysql_error());
   }
   $sql = "select  xy from coord";
   mysql_select_db('dbname');
   $retval = mysql_query( $sql, $conn );
   
   if(! $retval )
   {
      die('Could not enter data: ' . mysql_error());
   }
else
{
 while($d=mysql_fetch_assoc($retval))
  {
    echo $d["xy"];
  }
}
   
   mysql_close($conn);

?>

PROCESS:
place all the file in document root directory and run the start.sh file by
bash start.sh
on terminal and also start the mysql and apache2 services .
then find yours systems ip by 
ip addr show
,then connect your mobile device to same network ,your system already connected to .then type the ip address of your system in your mobiles browsers address bar 
then operate your mouse through web

Comments

Popular posts from this blog

ciphers continued--Vegerne Cipher and its application in php

Message Sending API (Unofficial) for Way2SMS [ PHP ]

Working with Frameworks of PHP- The MVC structure