Tag Archive for 'php'

Playing with the GoogleMaps API

You all know google and its wonderful GoogleMaps. There are many really cool things you can do with it; just visit google maps and check out the custom map overlays people are doing. However, if you want to embed a certain google map (one of your “my maps”) — you are out of luck, big time.

I stumbled across (or better, read about it shortly after we started the Tango 2.0 googlegroup) Peter Forret’s post on a web tool to embed google maps or also kml’s hosted, e.g. at maps.google.com. However, not all was well at that point, since the embedded map wasn’t centered where I wanted it to be centered. And that makes it a bit useless (I suspect some stupidity on my side or sluggish coding on Peter’s side for this). However, as this is the blogosphere, one of the comments was very cool and helpful: there is another web tool out there for embedding a kml on another website: http://www.dr2ooo.com/tools/maps/. Great, and much more versatile than Peter’s — another reason why the web is cool, as well as proof of the fact that the wheel does indeed get re-invented often. But nowadays you find out more easily about it. ;)

All was well. (don’t want to spoiler anyone, but those three words are the end of the Harry Potter Saga. Yep, and watch out for a very special effecty last movie, the book just stinks of it.) Check out the current version of my embedded google map on http://www.rhein-neckar-tango.de/milonga-karte. Nice enough, or is it?

Back to Tango 2.0: another member of the group, Peter Eyckerman, who has a great web 2.0 tango web page for Belgium.

And I realized: there is much more you can do with google maps than just embed. And, this being the web, I could just copy what he did — or do it myself.

DIY it is, then. :)

The next post will talk about some of the details, detours and results!

Google analytics plugin, modified

I am using the $dt->blog(); ยป Google analytics plugin here on this site, but for tracking outgoing link clicks I have had to modify the plugin like this:


add_filter('the_content', 'ga_addonclick', 10);

function ga_addonclick($value){

    if(get_option('ga_onclick')){

        $value = preg_replace("/<a href=\"([^\"]+)\”/e”,
        “‘<a href=\’$1\’ rel=\’nofollow\’ onclick=\”.ga_parseurl(’$1′).’\””   ,$value);
        }
        return $value;
}

function ga_parseurl($href){
    $onclickcode = stripslashes(get_option(’ga_onclick_code’));

    $href = str_replace(’http://’, ”, $href); 

    return str_replace(’$site’,$href,$onclickcode);
}




No more referrer spam

Dr Dave’s Referrer Karma is about the most useful anti-referrer spam tool I have seen so far. No more fiddling with .htaccess, no more redirecting spammers to their own pages. This simple php script keeps blacklists and whitelists, bans spammers when they are hitting your page too often, it also checks the reffererring URL for some indication of your site’s URL or even if it exists. For me it has reduced the referrer Spam I am getting to almost nothing at all - down from up to hundreds per day.

If you are looking for one simple solution - this is it. You only need MySQL as well as PHP - and off you go. Wrongfully detected “real surfers” are not blocked out but just sent to a page where they are told about the problem and then can access the site after a mouseclick.

Rating: 10/10.