$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>php - Detecting IP Address of someone using 'copy' function|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin8PV0评论
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.

Post a comment

comment list (0)

  1. No comments so far