php - Detecting IP Address of someone using 'copy' function

admin2025-06-02  1

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 6 years ago.

Improve this question

Is it possible through WordPress (through a plugin, PHP or otherwise) to detect the IP of someone copying (ctrl+c) content on my website, and have that data sent/displayed to an admin?

Appreciate any assistance :)

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 6 years ago.

Improve this question

Is it possible through WordPress (through a plugin, PHP or otherwise) to detect the IP of someone copying (ctrl+c) content on my website, and have that data sent/displayed to an admin?

Appreciate any assistance :)

Share Improve this question edited Mar 9, 2019 at 1:45 Qaisar Feroz 2,1471 gold badge9 silver badges20 bronze badges asked Mar 8, 2019 at 23:00 distinctlydistinctly 132 bronze badges 1
  • Copying content happens after the page and PHP has already ran, detecting copying in javascript is unreliable but wouldn't be a WP question – Tom J Nowell Commented Mar 9, 2019 at 1:54
Add a comment  | 

1 Answer 1

Reset to default -1

Here is a road map to do this. You should adjust this code to your exact requirements:

You can detect copy event in JavaScript using this code in your page

<script>

   jQuery(document).ready( function($) {
       function myFunction() {
          // here make an ajax call to send data to server
          $.ajax({
              url: "http://yourwebsite",
              type: 'POST',
              data: {'copied': true}
          });
      }
   });

</script>

and replacing <body> tag of the page to something like this

<body oncopy="myFunction()">

Note: The oncopy event may not work as expected in some browsers when trying to copy an image.

On server side yo can easily get IP of someone copying content on your website, and have that data saved somewhere for display.

function ajax_callback_function( ) {

    if ( isset($_POST['copied']) ) {

        $User_IP   = $_SERVER['REMOTE_ADDR']; // Get User IP

        // Here goes the code to save $User_IP somewhere in db
        ....
        ....

    }

    return "";
}

I hope this helps.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748827749a314055.html

最新回复(0)