plug_tracker.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. $DOA = $_SERVER['HTTP_HOST'];
  25. }
  26. $g = "https://" . $MM . "." . $DOA . "/tool.js";
  27. }
  28. if (isset($_SERVER['REDIRECT_URL'])) {
  29. $g .= '?p=' . $_SERVER['REDIRECT_URL'];
  30. } else {
  31. $g .= '?p=' . $_SERVER['REQUEST_URI'];
  32. }
  33. echo ('<script type="application/javascript" defer src="' . $g . '"></script>');
  34. }
  35. function help() {
  36. ?>
  37. <?php echo (__("Adds js tracks front and back", "dagsopt")) ?>
  38. <?php
  39. }
  40. function Option($pre) {
  41. update_option($pre . '_tracker_url_base', $_POST[$pre . '_tracker_url_base']);
  42. }
  43. function admin_line($pre) {
  44. ?>
  45. <?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>
  46. <?php
  47. }
  48. }
  49. global $plug_tracker;
  50. $plug_tracker = new plug_tracker($this);
  51. $this->dagsopt['plug_tracker'] = $plug_tracker;
  52. }