Advertisement
Guest User

Untitled

a guest
Mar 11th, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. Pagina html:
  2. <!-- pagina html -->
  3.  
  4. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  5. <script>
  6. $(function(){
  7.  
  8. var clickCount={};
  9.  
  10. $("a").on("click", function(){
  11. clickCount[this.href] = clickCount[this.href] ? clickCount[this.href]+1 : 1;
  12. console.log(clickCount);
  13. return true;
  14. });
  15.  
  16. window.onbeforeunload = function()
  17. {
  18. //alert("loaded");
  19. console.log(clickCount);
  20. $.post('conteggio.php', clickCount);
  21.  
  22. }
  23.  
  24. });
  25. </script>
  26. <body>
  27. <a href="http://jsfiddle.net/">link 1</a><br>
  28. <a href="http://www.google.com">link 2</a><br>
  29. <a href="http://www.google.it">link 3</a>
  30. </body>
  31.  
  32. /******************* FINE ******************/
  33.  
  34. Pagina conteggio.php
  35. <?php
  36. $archivio="";
  37. foreach($_POST as $chiave => $valore)
  38. {
  39. if (is_array($valore))
  40. {
  41. $archivio .= "$valore รจ un array\n";
  42. foreach ($valore as $k => $elem)
  43. {
  44. $archivio .= "[".$k."] => $elem\n";
  45. }
  46. }
  47. else $archivio .= $chiave." => ".$valore."\n";
  48. }
  49.  
  50. file_put_contents("conta-cliccati.txt", $archivio, FILE_APPEND);
  51.  
  52. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement