Jamie Lomas

share this - social buttons with php

Simple share this social buttons, this script uses php to get the current page.

demo

php

<?php
function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}
?>

js

<script type="text/javascript" src="ttps://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){$(".share1").click(function(){$("#share1").animate({height: 'toggle'});});});
</script>

css

.sharebox1 {padding:4px; border:solid 1px #ccc; background-color:#fff; -moz-border-radius: 7px; -webkit-border-radius: 7px; border-radius: 7px; behavior: url(fixes/border-radius.htc); margin-bottom:20px}
.sharebox1 img { border:0; padding:5px}
.sharebox1 h4 a{ font-family:Arial, Helvetica, sans-serif; color:#0099CC; text-decoration:none; display:block; font-size:18px}
.sharebox1 h4 { font-family:Arial, Helvetica, sans-serif; font-weight:normal; font-size:16px; padding:0; margin:5px 0 5px 8px;}
.sharebox1 ul li { list-style:none; margin:0px; padding:0px}
#share1 { display:none; overflow:hidden;}

html


<div class="sharebox1">
<h4><a href="#box_top" class="share1">Share this page +</a></h4>
<div id="share1">
<a href="http://twitter.com/home?status=Currently reading <?php echo curPageURL(); ?>" title="Twitter" target="_blank"><img src="codes/share/images/share1/twitter-32x32.png" alt="Tweet this"/></a>
<a href="http://www.facebook.com/sharer.php?u=<?php echo curPageURL(); ?>" title="Facebook" target="_blank"><img src="codes/share/images/share1/facebook-32x32.png" alt="Facebook"/></a>
<a href="http://reddit.com/submit?url=<?php echo curPageURL(); ?>" title="Reddit" target="_blank"><img src="codes/share/images/share1/reddit-32x32.png" alt="Reddit"/></a>
<a href="http://www.stumbleupon.com/submit?url=<?php echo curPageURL(); ?>" title="Stumbleupon" target="_blank"><img src="codes/share/images/share1/stumbleupon-32x32.png" alt="Stumbleupon"/></a>
<a href="http://digg.com/submit?url=<?php echo curPageURL(); ?>" title="Digg" target="_blank"><img src="codes/share/images/share1/digg-32x32.png" alt="Digg this"/></a>
<a href="http://del.icio.us/post?url=<?php echo curPageURL(); ?>" title="Delicious" target="_blank"><img src="codes/share/images/share1/delicious-32x32.png" alt="Delicious"/></a>
<a href="mailto:?subject=Sharing <?php echo curPageURL(); ?>" title="Email this page" target="_blank"></a></li>
</div></div>