HTTPS detection

jamesweston - May 17, 2009 - 21:33
Project:AddThis Button
Version:6.x-2.6
Component:Code
Category:bug report
Priority:normal
Assigned:jamesweston
Status:duplicate
Description

I modified the code in the addthis.module to detect for https connections

/**
* Theme the AddThis button.
*/
function theme_addthis_button($node, $teaser) {
  if(($_SERVER['HTTPS']) || ($_SERVER['HTTPS'] == 'on')){
   $httpsdetect = "https";
  }else{
   $httpsdetect = "http";
  }
  if (variable_get('addthis_dropdown_disabled', '0')) {
    return ( sprintf('
      <a href="http://www.addthis.com/bookmark.php"
        onclick="addthis_url   = location.href; addthis_title = document.title; return addthis_click(this);">
      <img src="%s" width="%d" height="%d" %s /></a>
      ',
      addslashes(variable_get('addthis_image', '$httpsdetect://secure.addthis.com/button1-share.gif')),
      addslashes(variable_get('addthis_image_width', '125')),
      addslashes(variable_get('addthis_image_height', '16')),
      addslashes(variable_get('addthis_image_attributes', 'alt=""'))
    ));
  }
  else {
    return ( sprintf('
      <a href="http://www.addthis.com/bookmark.php"
        onmouseover="return addthis_open(this, \'\', \'%s\', \'%s\')"
        onmouseout="addthis_close()"
        onclick="return addthis_sendto()"><img src="%s" width="%d" height="%d" %s /></a>
      <script type="text/javascript" src="' . $httpsdetect . '://secure.addthis.com/js/152/addthis_widget.js"></script>
      ',
      $teaser ? url('node/'. $node->nid, array('absolute' => 1) ) : '[URL]',
      $teaser ? addslashes($node->title) : '[TITLE]',
      addslashes(variable_get('addthis_image', '$httpsdetect://secure.addthis.com/button1-share.gif')),
      addslashes(variable_get('addthis_image_width', '125')),
      addslashes(variable_get('addthis_image_height', '16')),
      variable_get('addthis_image_attributes', 'alt=""')
    ));
  }
}

#1

wesku - May 18, 2009 - 16:05
Status:patch (to be ported)» duplicate

Thanks, but this has already been in the devel version for few months. I think it's about time to make a new release.

 
 

Drupal is a registered trademark of Dries Buytaert.