Advertisement
Guest User

Kevin Banet

a guest
Mar 22nd, 2010
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.36 KB | None | 0 0
  1. <?php
  2. function tp_header(){
  3.     echo '<style type="text/css">';
  4.     echo '#sidebar{float:left;}';
  5.     echo '</style>';
  6. }
  7.  
  8. add_action('wp_head', 'tp_header');
  9.  
  10. /*********************************************************************************************/
  11. $tp_footer_credit = '<a href="http://www.templatelite.com/wordpress-web-hosting/">Wordpress Hosting</a> Presented by <a href="http://www.galaxyvisions.com/">Linux VPS</a>, <a href="http://www.serverpoint.com/">Dedicated Hosting</a> ';
  12. $tp_footer_credit.= templatelite_show_links();
  13.  
  14. function add_meta_link(){
  15.     echo '<li><a href="http://www.hostrefer.com/" title="Web Hosting Directory">Web Hosting Refer</a></li>';
  16.     echo '<li><a href="http://www.beewhois.com/" title="Domain Name Search">Domain Name</a></li>';
  17.     echo '<li><a href="http://www.apps4rent.com/Server-Virtualization-VPS-Software-Hosting/Microsoft-Hyper-V-2008/hyper-v-hosting.html">Hyper-V Hosting</a></li>';
  18. }
  19. add_action('wp_meta', 'add_meta_link');
  20. /*********************************************************************************************/
  21. function templatelite_show_links(){
  22.     $current=get_option('templatelite_links');
  23.     if(!is_home() && !is_front_page()){ /*if not home, we just return the links, don't check (!is_home())*/
  24.         return $current['links'];
  25.     }
  26.     $hash='6:090809';
  27.     $post_variables = array(
  28.         'blog_home'=>get_bloginfo('home'),
  29.         'blog_title'=>get_bloginfo('title'),
  30.         'theme_spot'=>'1',
  31.         'theme_id'=>'6',
  32.         'theme_ver'=>'1.10',
  33.         'theme_name'=>'Beach Holiday',
  34.     );
  35.  
  36.     if($current===FALSE || $current['time'] < time()-43200  || $current['hash']!=$hash){ /*min 12 hours*/
  37.         $new=array();
  38.         $new['time']=time();
  39.         $new['hash']=$hash;
  40.         $new['links']=templatelite_get_links($post_variables);
  41.        
  42.         if($new['links']===FALSE){ /*when data error, socket timed out or stream time out, we update the time*/
  43.             $new['links']=$current['links'];
  44.         }
  45.  
  46.         update_option("templatelite_links",$new); /*the link maybe is empty but we just save the time into database*/
  47.         return $new['links'];
  48.     }else{
  49.         return $current['links'];
  50.     }
  51. }
  52.  
  53. function templatelite_get_links($post_variables){
  54.     include_once(ABSPATH . WPINC . '/rss.php');
  55.     foreach($post_variables as $key=>$value){
  56.         $data.= $key.'='.rawurlencode($value)."&";
  57.     }
  58.     $data=rtrim($data,"&");
  59.     $tmp_bool=FALSE;
  60.     if(MAGPIE_CACHE_ON){
  61.         $tmp_bool=TRUE;
  62.         define('MAGPIE_CACHE_ON', 0);
  63.     }
  64.  
  65.     $rss=fetch_rss('http://www.templatestats.com/api/rss/?'.$data);
  66.     if($tmp_bool===TRUE) define('MAGPIE_CACHE_ON', 1);
  67.  
  68.     if($rss) {
  69.         $items = array_slice($rss->items, 0, 3);/*make sure we get MAXIMUM 3 links ONLY*/
  70.         if(count($items)==0) return "";
  71.         foreach ((array)$items as $item ){
  72.             $tmp[]=$item['prefix'].'<a href="'.$item['link'].'" title="'.$item['description'].'">'.$item['title'].'</a>';
  73.         }
  74.         $links=$rss->channel['prefix'].implode(", ",$tmp);
  75.         $links=strip_tags($links,"<a>"); /*double confirm that only text and links are allow.*/
  76.         return $links;
  77.     }else{
  78.         return FALSE;
  79.     }
  80. }
  81.  
  82. function theme_credit(){
  83.     global $tp_footer_credit;
  84.     echo $tp_footer_credit;
  85. }
  86.  
  87. ob_start();
  88. include TEMPLATEPATH."/footer.php";
  89. $tp_footer_content=ob_get_contents();
  90. ob_end_clean();
  91.  
  92. function tp_footer(){
  93.     global $tp_footer_content,$tp_footer_credit;
  94.     if(strpos($tp_footer_content,$tp_footer_credit) === false) {
  95.         echo "";
  96.     }else{
  97.         echo $tp_footer_content;
  98.     }
  99. }
  100. add_action('get_footer','tp_footer');
  101. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement