Plugin Directory

Changeset 496995


Ignore:
Timestamp:
01/29/2012 07:37:49 PM (14 years ago)
Author:
aitosoftware
Message:

Creating/signing in to a PulseMaps account now required (so we can
provide better support and reduce abuse and fraud).

Location:
pulsemaps/trunk
Files:
1 added
6 edited
1 moved

Legend:

Unmodified
Added
Removed
  • pulsemaps/trunk/pm-config.php

    r462179 r496995  
    11<?php
    22
    3 global $pulsemaps_api;
    4 $pulsemaps_api = 'http://api.pulsemaps.com';
    5 
    6 global $pulsemaps_site;
    7 $pulsemaps_site = 'http://pulsemaps.com';
     3global $pulsemaps_url;
     4$pulsemaps_url = 'https://pulsemaps.com';
    85
    96global $pulsemaps_version;
    10 $pulsemaps_version = 8;
     7$pulsemaps_version = 9;
    118
    129$local_config = dirname(__FILE__) . '/pm-config-local.php';
  • pulsemaps/trunk/pm-proxy.php

    r486545 r496995  
    11<?php
    22
    3 /*  Copyright 2011 Aito Software Inc. (email : [email protected])
     3/*  Copyright 2011-2012 Aito Software Inc. (email : [email protected])
    44
    55    This program is free software; you can redistribute it and/or modify
     
    1717*/
    1818
    19 while(ob_get_level()) ob_end_clean();
    20 header('Connection: close');
    21 ignore_user_abort();
    22 ob_start();
    23 
    2419require_once('pm-config.php');
    25 $c = curl_init($pulsemaps_api . '/mapInfo/wp/');
    26 $data = array('key' => $_POST['key']);
    27 curl_setopt($c, CURLOPT_POSTFIELDS, $data);
     20$c = curl_init($pulsemaps_url . '/mapInfo/wp/');
     21curl_setopt($c, CURLOPT_POSTFIELDS, $_POST);
    2822curl_exec($c);
    2923$code = curl_getinfo($c, CURLINFO_HTTP_CODE);
     
    3327    die;
    3428}
    35 
    36 $size = ob_get_length();
    37 header("Content-Length: $size");
    38 ob_end_flush();
    39 flush();
    40 
    41 require('../../../wp-load.php');
    42 
    43 $c = curl_init($pulsemaps_api . '/mapInfo.json');
    44 $opts = get_option('pulsemaps_options');
    45 $data = array('key' => $opts['key']);
    46 curl_setopt($c, CURLOPT_POSTFIELDS, $data);
    47 curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
    48 curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 5);
    49 $ret = curl_exec($c);
    50 $code = curl_getinfo($c, CURLINFO_HTTP_CODE);
    51 curl_close($c);
    52 if ($code == '200') {
    53     $d = json_decode($ret, true);
    54     if ($opts['plan'] != $d['planTag']) {
    55         $opts['plan'] = $d['planTag'];
    56         if ($opts['plan'] == 'free') {
    57             $opts['track_all'] = false;
    58         }
    59         update_option('pulsemaps_options', $opts);
    60     }
    61 }
  • pulsemaps/trunk/pm-settings-page.php

    r462179 r496995  
    11<?php
    22
    3 /*  Copyright 2011 Aito Software Inc. (email : [email protected])
     3/*  Copyright 2011-2012 Aito Software Inc. (email : [email protected])
    44
    55    This program is free software; you can redistribute it and/or modify
     
    3636    echo "<script type='text/javascript' src='$url_js'></script>\n";
    3737
    38     global $pulsemaps_api;
     38    global $pulsemaps_url;
    3939    $options = get_option('pulsemaps_options');
    4040    $id = $options['id'];
    41     $widget_url = "$pulsemaps_api/widget.js?id=123456789&notrack=1&target=widget-preview";
    42     $url_load = plugins_url('pm-plan.php', __FILE__);
     41    $widget_url = "$pulsemaps_url/widget.js?id=123456789&notrack=1&target=widget-preview";
     42    $url_load = plugins_url('pm-proxy.php', __FILE__);
    4343?>
    4444<script type='text/javascript'>
     
    4848  jQuery(document).ready(function() {
    4949    pulsemaps.setHooks('<?php echo $widget_url; ?>');
    50     jQuery("#pulsemaps_plan_load").load("<?php echo $url_load; ?>", {key: "<?php echo $options['key']; ?>"});
     50    jQuery("#pulsemaps_plan_load").load("<?php echo $url_load; ?>",
     51                                        {key: "<?php echo $options['key']; ?>",
     52                                         version: "<?php echo pulsemaps_plugin_version(); ?>",
     53                                         svn_id:  "$Id: $",
     54                                         wp_version: "<?php global $wp_version; echo $wp_version; ?>",
     55                                         php_version: "<?php echo phpversion(); ?>"});
    5156  });
    5257</script>
     
    6974
    7075function pulsemaps_options_page() {
     76    global $pulsemaps_url;
    7177    $opts = get_option('pulsemaps_options', array());
    7278    $id = $opts['id'];
    73     $style = get_option('pulsemaps_widget', 'default');
    74     global $pulsemaps_api;
    7579    $siteurl = get_option('siteurl');
    76     if (!pulsemaps_tracking_active()) {
    77         echo '<div class="error"><p><strong>Visitor tracking is inactive. Drag the PulseMaps widget on a sidebar on the <a href="';
    78         echo get_option('siteurl') . '/wp-admin/widgets.php';
    79         echo '">widget admin page</a>.</strong></p></div>';
    80     }
    81     echo "<iframe style=\"display: none;\" src=\"$pulsemaps_api/mapOwner/?map=$id\"></iframe>";
    8280?>
    8381<div class="wrap">
    8482<div id="icon-options-general" class="icon32"><br></div>
    8583<h2>PulseMaps Visitor Map</h2>
    86 <div id="pulsemaps_plan">
    8784<div id="pulsemaps_descr">
    88 <div id="pulsemaps_plan_load">
     85<div id="pulsemaps_plan_load" <?php if (!$opts['activated']) { echo 'style="display: none;"'; } ?>>
    8986<img src="<?php echo $siteurl; ?>/wp-admin/images/loading.gif" alt="loading...">
    9087</div>
    9188</div>
    92 <div id="pulsemaps_map"></div>
    93 </div>
    94 <script type="text/javascript" id="pulsemaps_<?php echo $id; ?>" src="<?php echo $pulsemaps_api; ?>/map.js?id=<?php echo $id; ?>&target=pulsemaps_map"></script>
    95 <div id="pulsemaps_settings">
     89<form style="display: none;" id="pulsemaps_activate" action="options.php" method="post">
     90<?php settings_fields('pulsemaps_options'); ?>
     91<input type="hidden" name="pulsemaps_options[activated]" value="1">
     92<input type="hidden" name="pulsemaps_options[frameheight]" value="<?php echo $opts['frameheight']; ?>">
     93</form>
     94<script>
     95function pulsemaps_handler(height, active, reload)
     96{
     97    document.getElementById('pulsemaps_iframe').height = parseInt(height);
     98    if (active != 0) {
     99        jQuery('#pulsemaps_settings').show();
     100        jQuery("input[name='pulsemaps_options[frameheight]']").val(height);
     101        jQuery.post('options.php', jQuery('#pulsemaps_activate').serialize(),
     102                    function() { if (reload) { top.location.reload(true); } });
     103    }
     104}
     105</script>
     106<?php if (!$opts['activated']) { ?>
     107<iframe src="<?php echo "$pulsemaps_url/maps/$id/wp-info.html?settings_url=";
     108                   echo urlencode(pulsemaps_settings_url());
     109                   echo "&plugin_url=" . urlencode(plugins_url('', __FILE__));
     110                   echo "&admin_url=" . urlencode(pulsemaps_admin_url()); ?>"
     111        id="pulsemaps_iframe"
     112        style="width: 100%; overflow-y: hidden;" scrolling="no"></iframe>
     113<?php
     114    }
     115    $style = get_option('pulsemaps_widget', 'default');
     116?>
     117    <div id="pulsemaps_settings" <?php if (!$opts['activated']) { echo 'style="display: none;"'; } ?>>
    96118<form action="options.php" method="post">
    97119     <?php settings_fields('pulsemaps_options'); ?>
     
    121143    add_settings_field('pulsemaps_widget_bgcolor', 'Background', 'pulsemaps_widget_bgcolor', 'pulsemaps', 'pulsemaps_options');
    122144    add_settings_field('pulsemaps_widget_open',    'New Window', 'pulsemaps_widget_opennew',  'pulsemaps', 'pulsemaps_options');
    123     add_settings_field('pulsemaps_widget_dots','Real-time dots', 'pulsemaps_widget_dots', 'pulsemaps', 'pulsemaps_options');
     145    add_settings_field('pulsemaps_widget_dots',    'Real-time dots', 'pulsemaps_widget_dots', 'pulsemaps', 'pulsemaps_options');
    124146    add_settings_field('pulsemaps_widget_meta',    'Text above small map', 'pulsemaps_widget_showmeta', 'pulsemaps', 'pulsemaps_options');
    125147    if ($options['plan'] != 'free') {
    126         add_settings_field('pulsemaps_track_all',   'Track without widget', 'pulsemaps_track_all',  'pulsemaps', 'pulsemaps_options');
     148        add_settings_field('pulsemaps_track_all',  'Track without widget', 'pulsemaps_track_all',  'pulsemaps', 'pulsemaps_options');
    127149    }
    128150}
     
    276298}
    277299
     300function pulsemaps_validate_bool(&$options, $input, $field) {
     301    if (isset($input[$field])) {
     302        $options[$field] = (bool)$input[$field];
     303    }
     304}
    278305
    279306function pulsemaps_options_validate($input) {
     
    286313    pulsemaps_validate_color($options, $input, 'custom_color');
    287314    pulsemaps_validate_color($options, $input, 'custom_bgcolor');
     315    pulsemaps_validate_bool($options, $input, 'widget_dots');
     316    pulsemaps_validate_bool($options, $input, 'track_all');
     317    pulsemaps_validate_bool($options, $input, 'widget_new_window');
     318    pulsemaps_validate_bool($options, $input, 'activated');
     319    pulsemaps_validate_bool($options, $input, 'congrats');
    288320
    289321    if (isset($input['widget_type'])) {
     
    301333    }
    302334
    303     if (isset($input['widget_new_window'])) {
    304         $options['widget_new_window'] = true;
    305     } else {
    306         $options['widget_new_window'] = false;
    307     }
    308 
    309335    if (isset($input['widget_meta'])) {
    310336        $widget_meta = trim($input['widget_meta']);
     
    314340    }
    315341
    316     if (isset($input['widget_dots'])) {
    317         $options['widget_dots'] = true;
    318     } else {
    319         $options['widget_dots'] = false;
    320     }
    321 
    322     if (isset($input['track_all'])) {
    323         $options['track_all'] = true;
    324     } else {
    325         $options['track_all'] = false;
    326     }
    327 
    328     if (isset($input['settings_visited'])) {
    329         $options['settings_visited'] = true;
    330     }
    331 
    332342    return $options;
    333343}
  • pulsemaps/trunk/pm-widget.php

    r486205 r496995  
    2626    function widget($args, $instance) {
    2727        global $wpdb;
    28         global $pulsemaps_api;
    29         global $pulsemaps_site;
     28        global $pulsemaps_url;
    3029        extract( $args );
    3130        $title = apply_filters('widget_title', $instance['title']);
     
    4039        $width = $opts['widget_width'];
    4140
    42         $url = "$pulsemaps_api/widget.js?id=$id&width=$width";
     41        $url = "$pulsemaps_url/widget.js?id=$id&width=$width";
    4342        if ($opts['widget_type'] == 'satellite') {
    4443            $url .= "&type=satellite";
  • pulsemaps/trunk/pulsemaps.php

    r486205 r496995  
    44Plugin URI: http://pulsemaps.com/wordpress/
    55Description: Show off your visitors on the world map.  When people around the world visit your blog, the corresponding areas on the heat map widget light up!
    6 Version: 1.4.6
     6Version: 1.5
    77Author: Aito Software Inc.
    88License: GPLv2 or later
    99*/
    1010
    11 /*  Copyright 2011-2012 Aito Software Inc. (email : [email protected])
     11/*  Copyright 2011, 2012 Aito Software Inc. (email : [email protected])
    1212
    1313    This program is free software; you can redistribute it and/or modify
     
    3030
    3131function pulsemaps_register() {
    32     global $pulsemaps_api;
    33     $c = curl_init($pulsemaps_api . '/register');
     32    global $pulsemaps_url;
     33    $c = curl_init($pulsemaps_url . '/register');
    3434    $data = array('name' => get_option('blogname'),
    3535                  'email' => get_option('admin_email'),
     
    8989    }
    9090
    91     if (!isset($opts['settings_visited'])) {
    92         $opts['settings_visited'] = !$first;
     91    if (!isset($opts['congrats'])) {
     92        $opts['congrats'] = false;
     93    }
     94
     95    if (!isset($opts['activated'])) {
     96        $opts['activated'] = true;
    9397    }
    9498
     
    115119    $opts = get_option('pulsemaps_options', array());
    116120
    117     if (!isset($opts['key']) || !isset($opts['id'])) {
     121    if (!pulsemaps_registered()) {
    118122        $ret = pulsemaps_register();
    119123        if ($ret['status'] == 'ok') {
     
    143147        $opts['widget_type'] = 'plain';
    144148    }
     149    if (!isset($opts['congrats'])) {
     150        $opts['congrats'] = false;
     151    }
     152    if (!isset($opts['activated'])) {
     153        $opts['activated'] = false;
     154    }
    145155
    146156    update_option('pulsemaps_options', $opts);
     
    156166}
    157167
    158 
    159 function pulsemaps_settings_visited() {
    160     $opts = get_option('pulsemaps_options', array());
    161     return $opts['settings_visited'];
    162 }
    163 
     168function pulsemaps_registered() {
     169    $opts = get_option('pulsemaps_options', array());
     170    return isset($opts['key']) && isset($opts['id']);
     171}
     172
     173function pulsemaps_activated() {
     174    $opts = get_option('pulsemaps_options', array());
     175    return $opts['activated'];
     176}
     177
     178function pulsemaps_plugin_version() {
     179    $plugin_data = get_plugin_data(__FILE__);
     180    $plugin_version = $plugin_data['Version'];
     181    return $plugin_version;
     182}
     183
     184function pulsemaps_admin_url() {
     185    if (function_exists('admin_url')) {
     186        return admin_url();
     187    } else {
     188        return get_option('siteurl') . '/wp-admin/';
     189    }
     190}
     191
     192function pulsemaps_settings_url() {
     193    return pulsemaps_admin_url() . 'options-general.php?page=pulsemaps';
     194}
    164195
    165196function pulsemaps_activate_notice() {
    166     global $pulsemaps_api;
     197    global $pulsemaps_url;
    167198    $opts = get_option('pulsemaps_options');
    168199    $id = $opts['id'];
    169     if (substr($_SERVER["PHP_SELF"], -11) == 'plugins.php' && !pulsemaps_tracking_active()) {
    170         echo "<iframe style=\"display: none;\" src=\"$pulsemaps_api/mapOwner/?map=$id\"></iframe>";
    171         echo '<div class="error"><p><strong>Activate PulseMaps visitor tracking on the <a href="';
    172         echo get_option('siteurl') . '/wp-admin/widgets.php';
    173         echo '">widget admin page</a>.  Check also the <a href="';
    174         echo get_option('siteurl') . '/wp-admin/options-general.php?page=pulsemaps';
     200    if (!pulsemaps_activated() && substr($_SERVER["PHP_SELF"], -11) != 'general.php'
     201        && $_GET["page"] != "pulsemaps") {
     202        echo '<div class="error"><p><strong>Activate the PulseMaps service on the <a href="';
     203        echo pulsemaps_settings_url();
    175204        echo '">settings page</a>.</strong></p></div>';
    176205    } else if (substr($_SERVER["PHP_SELF"], -11) == 'widgets.php') {
     
    180209        }
    181210        echo '><p><strong>Drag the PulseMaps widget to a sidebar on the right to activate.</strong></p></div>';
    182         echo '<div ';
    183         if (!pulsemaps_settings_visited()) {
    184             echo 'id="pulsemaps_activated" ';
    185         } else {
    186             echo 'style="display: none;" ';
    187         }
    188         echo 'class="updated"><p><strong>Remember to visit your <a href="';
    189         echo get_option('siteurl'). '/wp-admin/options-general.php?page=pulsemaps';
    190         echo '">PulseMaps settings page</a> to customize your widget.</strong></p></div>';
    191     } else {
    192         if (!pulsemaps_settings_visited()) {
    193             echo '<div class="updated"><p><strong>Remember to visit your <a href="';
     211        if (!$opts['congrats']) {
     212            $opts['congrats'] = true;
     213            update_option('pulsemaps_options', $opts);
     214            echo '<div id="pulsemaps_activated" style="display: none;" ';
     215            echo 'class="updated"><p><strong>All done! You can always visit the <a href="';
    194216            echo get_option('siteurl'). '/wp-admin/options-general.php?page=pulsemaps';
    195217            echo '">PulseMaps settings page</a> to customize your widget.</strong></p></div>';
    196218        }
     219    }  else if (!pulsemaps_tracking_active() && pulsemaps_activated()) {
     220        echo '<div class="error"><p><strong>Enable the PulseMaps widget on the <a href="';
     221        echo get_option('siteurl') . '/wp-admin/widgets.php';
     222        echo '">widget admin page</a> to start mapping visitors.</strong></p></div>';
    197223    }
    198224}
     
    265291    $opts = get_option('pulsemaps_options');
    266292    if ($opts['track_all'] && !is_user_logged_in()) {
    267         global $pulsemaps_api;
     293        global $pulsemaps_url;
    268294        ?>
    269295<script type="text/javascript">
    270296(function() {
    271297   var pm = document.createElement('script'); pm.type = 'text/javascript'; pm.async = true;
    272    pm.src = "<?php echo $pulsemaps_api .'/tracker.js?id='.$opts['id']; ?>";
     298   pm.src = "<?php echo $pulsemaps_url .'/tracker.js?id='.$opts['id']; ?>";
    273299   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(pm, s);
    274300})();
     
    279305
    280306add_action('wp_head', 'pulsemaps_async_tracker');
     307
     308
     309function pulsemaps_bigmap($atts) {
     310    $opts = get_option('pulsemaps_options', array());
     311    $id = $opts['id'];
     312    global $pulsemaps_url;
     313    $url = $pulsemaps_url . '/map.js?id=' . $id . '&target=pulsemaps_map';
     314    return "<div id=\"pulsemaps_map\" style=\"width: 512; height: 320px\"></div>\n"
     315        . "<script type=\"text/javascript\">\n"
     316        . "(function() {\n"
     317        . "  var pm=document.createElement(\"script\");\n"
     318        . "  pm.type = 'text/javascript';\n"
     319        . "  pm.async = true;\n"
     320        . "  pm.src = '" . $url . "';\n"
     321        . "  var s = document.getElementById('pulsemaps_map');\n"
     322        . "  s.parentNode.appendChild(pm);\n"
     323        . "})();\n"
     324        . "</script>\n";
     325}
     326
     327add_shortcode('pulsemaps', 'pulsemaps_bigmap');
  • pulsemaps/trunk/readme.txt

    r486205 r496995  
    88Requires at least: 2.9
    99Tested up to: 3.3.1
    10 Stable tag: 1.4.6
     10Stable tag: 1.5
    1111
    1212Show off your visitors on the world map. When people around the world visit your blog, the corresponding areas on the heat map widget light up!
     
    6868
    6969== Changelog ==
     70
     71= 1.5 =
     72
     73* Creating/signing in to a PulseMaps account now required (so we can
     74  provide better support and reduce abuse and fraud).
    7075
    7176= 1.4.6 =
  • pulsemaps/trunk/style.css

    r414563 r496995  
    1 #pulsemaps_plan {
    2     width: 1000px;
    3 }
    4 
    5 #pulsemaps_map {
    6     width: 512px;
    7     height: 280px;
    8     float: right;
    9 }
    10 
    111#pulsemaps_descr {
    12     width: 450px;
    13     float: left;
     2    margin-bottom: 20px;
    143}
    154
Note: See TracChangeset for help on using the changeset viewer.