Top SEM and SEO Tips    

Archive for April, 2010

PHP Classes Constant Arrays

Monday, April 12th, 2010

This is something I fought on Friday and got to the realization that PHP classes don’t support array constants. Not sure why not but sometimes you’re stuck with a situation and need a work around. In this instance I used static class variables in place of consts:

{code type=php}

class AutoReport
{

// This should be a constant but PHP constants don’t handle arrays

static $DelayTimes = array( 0 => ‘Run Once’ ,
60 => ’1 Minute’ ,
120 => ’2 Minutes’ ,
180 => ’3 Minutes’ ,
240 => ’4 Minutes’ ,
300 => ’5 Minutes’ ,
600 => ’10 Minutes’ ,
900 => ’15 Minutes’ ,
1800 => ’30 Minutes’ ,
3600 => ’1 Hour’ ,
7200 => ’2 Hours’ ,
14400 => ’4 Hours’ ,
43200 => ’12 Hours’ ,
) ;

}

{/code}

And when referencing this:

{code type=php}

AutoReport::$DelayTimes

{/code}



Google Maps Centering and Zooming

Friday, April 9th, 2010

OK fought this for a while yesterday so thought I would share. The original objective was to display a Google Map with pointers for all the locations on the map, the map would then be re-zoomed and centered so all points show. Sounds simple! After hours of fighting the system the big problem is Google Maps wants to have the map centered and zoomed before adding any pointers. Here’s my take on this, BTW this was built from various other authors code snippets but the combination of them to make it work is my original code:

First off you need a div to put the map into.

{code type=html}

<div id=’FacilityMap’ class=’MultipleFacilityMap’></div>

{/code}

I then added CSS to make the map the correct size:

{code type=css}

#FacilityMap *{
border:none;
}
#FacilityMap a{
font-weight:bold;
}
#FacilityMap a.more{
font-weight:normal;
text-decoration:underline;
}
.IndividualFacilityMap{
width: 450px;
height: 350px;
}
.MultipleFacilityMap{
width: 650px;
height: 550px;
}

{/code}

And then in javascript added the following code:

{code type=php}
function createMarker(point,title,html) {
var markerOpts = { title: title } ;
var marker = new GMarker(point, markerOpts );
GEvent.addListener(marker, “click”, function() {
marker.openInfoWindowHtml(html);
});
return marker;
}

// Set up markers with info windows
var markers = [];
var bound = new GLatLngBounds();
<?php foreach( $FacilityMap as $FacilityInfo ) : ?>
var posn = new GLatLng(<?=$FacilityInfo['latitude']?>,<?=$FacilityInfo['longitude']?>);
var marker = createMarker(posn,”<?=$FacilityInfo['FacilityName']?>”,’<div style=”width:240px”><a href=”<?=$FacilityInfo['DRC_URL']?>”><?=$FacilityInfo['FacilityName']?></a><br /><?=$FacilityInfo['streetaddress']?><\/div>’)
markers.push( marker );
bound.extend( posn );
<?php endforeach; ?>
// Display the map, with some controls and set the initial location
var map = new GMap2(document.getElementById(“FacilityMap”));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());

var level = map.getCurrentMapType().getBoundsZoomLevel(bound, map.getSize());
var ne = bound.getNorthEast();
var sw = bound.getSouthWest();

map.setCenter(new GLatLng((ne.lat() + sw.lat()) / 2.0 , (ne.lng() + sw.lng()) / 2.0 ), level);
map.enableDoubleClickZoom();
for ( i=0; i < markers.length; i++ )
{

map.addOverlay(markers[i]);

}

{/code}



Seth on the sweet soda tax

Friday, April 9th, 2010

Interesting take from Seth Godin on the soda tax proposed in New York http://sethgodin.typepad.com/seths_blog/2010/04/rights-and-responsibilities.html

I find it fascinating that companies can sell a product that’s (supposedly) bad for you, they have alternatives available (including diet, water, and other beverages), and yet won’t help their customers move to the healthier alternatives. This isn’t tobacco where there is no healthier alternative, you either smoke or you don’t – here they could help wean people off full HFCS sodas to diet without losing their market or their sales.

This seems typical big company head in the sand thinking – if we fight it we keep the status quo. But look what happened to the auto companies who fought change – they lost market share to competitors who did listen and respond.

After reading how the banks are still massaging their balance sheets i would like to (just once) see a large company do the right thing.



Issues Creating and Downloading File in IE from PHP

Thursday, April 8th, 2010

Took a while to fix this one. The problem is you create a download button in HTML that leads to a PHP program that creates a file that Internet Explorer should download. The code works fine in Firefox just not IE.

The original code was something like:
{code type=php}
header(“Pragma: no-cache”);
header(“Expires: 0″);

header(“Content-disposition: attachment; filename=\”export.xls\”;”);
header(“Content-Type: application/vnd.ms-excel”);
{/code}
Which works in Firefox but not IE. The new code is:
{code type=php}header(“Pragma: “);
header(“Cache-Control: “);

header(“Content-disposition: attachment; filename=\”export.xls\”;”);
header(“Content-Type: application/vnd.ms-excel”);
{/code}
And that works fine.



Online Reputation Management Extortion

Tuesday, April 6th, 2010

While extortion might seem a harsh word there have now been three companies that have found our false complaints in ripoffreport and have contacted us to inquire about helping fix the issue. Now obviously if they did any due-diligence they would know we to do online reputation management however these companies are obviously too ignorant to do even basic background checking before sending their offers of help (for a fee of course).

List of shame:

  1. Repspinner – first to respond through phone and email – twice.
  2. www.Reputation-Armor.net – just email so far
  3. www.reputationstore.com- just email so far

So why did I use the word extortion? Well we’ve already proved the complaints are false (they say we’re a gym for a starters) so someone, somewhere decided that loading false reports into sites such as ripoffreport was a good way to make money, and according to Wikipedia

Exaction refers not only to extortion or the unlawful demanding and obtaining of something through force, but additionally, in its formal definition, means the infliction of something such as pain and suffering or making somebody endure something unpleasant.

So these companies may, or may not, have written the sham reports but they’re sure trying to cash in on them.