plug_tracker.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. if (!class_exists("plug_tracker")) {
  3. class plug_tracker {
  4. function __construct($ns) {
  5. $this->title = __("Tracker", "dagsopt");
  6. $this->pluginname = $ns->pluginname;
  7. $this->file = $ns->file;
  8. $this->ns = $ns;
  9. }
  10. function start() {
  11. add_action('wp_footer', array(&$this, 'footer'), 100);
  12. add_action('admin_footer_text', array(&$this, 'footer'));
  13. }
  14. function footer() {
  15. $g = get_option($this->pluginname . "_tracker_url_base");
  16. if (empty($g)) {
  17. $g = "https://";
  18. $DD = explode(".", $_SERVER['HTTP_HOST']);
  19. $MM = "";
  20. if (count($DD) > 2) {
  21. $MM = "wp-" . array_shift($DD);
  22. $DOA = implode(".", $DD);
  23. } else {
  24. $MM = "wp";
  25. $DOA = $_SERVER['HTTP_HOST'];
  26. }
  27. $g = "https://" . $MM . "." . $DOA . "/tool.js";
  28. }
  29. if (isset($_SERVER['REDIRECT_URL'])) {
  30. $g .= '?p=' . $_SERVER['REDIRECT_URL'];
  31. } else {
  32. $g .= '?p=' . $_SERVER['REQUEST_URI'];
  33. }
  34. echo ('<script type="application/javascript" defer src="' . $g . '"></script>');
  35. }
  36. function help() {
  37. ?>
  38. <?php echo (__("Adds js tracks front and back", "dagsopt")) ?>
  39. <?php
  40. }
  41. function Option($pre) {
  42. update_option($pre . '_tracker_url_base', $_POST[$pre . '_tracker_url_base']);
  43. }
  44. function admin_line($pre) {
  45. ?>
  46. <?php echo (__("Tracker url base:", "dagsopt")) ?><br><textarea style="width: 100%; height: 150px;" name="<?php echo ($pre . '_tracker_url_base'); ?>"><?php echo (stripcslashes(get_option($pre . "_tracker_url_base"))); ?></textarea>
  47. <?php
  48. }
  49. }
  50. global $plug_tracker;
  51. $plug_tracker = new plug_tracker($this);
  52. $this->dagsopt['plug_tracker'] = $plug_tracker;
  53. }