Sunday, November 1, 2009

Adding Search Rank to your Expression Engine Search Module

Search Rank is as simple as counting the number of occurrences of the keyword terms in the result. Here are the changes to make to your mod.search.php file, briefly:


Add the case option in the orderby:

case 'rank' : $end .= " ORDER BY occurrences ";
break;


Modify the query:

$sql = "SELECT DISTINCT(t.entry_id), t.entry_id, t.weblog_id, t.forum_topic_id, t.author_id, t.ip_address, t.title, t.url_title, t.status, t.dst_enabled, t.view_count_one, t.view_count_two, t.view_count_three, t.view_count_four, t.allow_comments, t.comment_expiration_date, t.allow_trackbacks, t.sticky, t.entry_date, t.year, t.month, t.day, t.entry_date, t.edit_date, t.expiration_date, t.recent_comment_date, t.comment_total, t.trackback_total, t.sent_trackbacks, t.recent_trackback_date, t.site_id as entry_site_id,

w.blog_title, w.blog_name, w.search_results_url, w.search_excerpt, w.blog_url, w.comment_url, w.tb_return_url, w.comment_moderate, w.weblog_html_formatting, w.weblog_allow_img_urls, w.weblog_auto_link_urls, w.enable_trackbacks, w.trackback_use_url_title, w.trackback_field, w.trackback_use_captcha, w.trackback_system_enabled,
m.username, m.email, m.url, m.screen_name, m.location, m.occupation, m.interests, m.aol_im, m.yahoo_im, m.msn_im, m.icq, m.signature, m.sig_img_filename, m.sig_img_width, m.sig_img_height, m.avatar_filename, m.avatar_width, m.avatar_height, m.photo_filename, m.photo_width, m.photo_height, m.group_id, m.member_id, m.bday_d, m.bday_m, m.bday_y, m.bio,
md.*,
wd.*,

(LENGTH(t.title) - LENGTH(REPLACE(LOWER(t.title), LOWER('".$DB->escape_str((sizeof($terms) == 1) ? $terms[0] : $this->keywords)."'), '')))/LENGTH('".$DB->escape_str((sizeof($terms) == 1) ? $terms[0] : $this->keywords)."') + (LENGTH(wd.field_id_1) - LENGTH(REPLACE(LOWER(wd.field_id_1), LOWER('".$DB->escape_str((sizeof($terms) == 1) ? $terms[0] : $this->keywords)."'), '')))/LENGTH('".$DB->escape_str((sizeof($terms) == 1) ? $terms[0] : $this->keywords)."') + (LENGTH(wd.field_id_2) - LENGTH(REPLACE(LOWER(wd.field_id_2), LOWER('".$DB->escape_str((sizeof($terms) == 1) ? $terms[0] : $this->keywords)."'), '')))/LENGTH('".$DB->escape_str((sizeof($terms) == 1) ? $terms[0] : $this->keywords)."') AS `occurrences`

FROM exp_weblog_titles AS t
LEFT JOIN exp_weblogs AS w ON t.weblog_id = w.weblog_id
LEFT JOIN exp_weblog_data AS wd ON t.entry_id = wd.entry_id
LEFT JOIN exp_members AS m ON m.member_id = t.author_id
LEFT JOIN exp_member_data AS md ON md.member_id = m.member_id
WHERE t.entry_id IN (";

foreach ($query->result as $row)
{
$sql .= $row['entry_id'].',';
}

$sql = substr($sql, 0, -1).') '.$end;

return $sql;


Modify the query result:

$query = $DB->query(preg_replace("/SELECT(.*?)\s+FROM\s+/is", "SELECT COUNT(*) AS count, COUNT(*) AS `occurrences` FROM ", $sql));


Modify the language term for rank:

'lang:rank ' => $LANG->line('search_rank'),




With the modified mod.search.php module in place, you will want to change your Search form input to "rank":

<input type="hidden" name="orderby" value="rank" />


You'll be searching by rank in no time. Enjoy.

Wednesday, December 10, 2008

Acrobat 9 Slow moving comments and stickies

I've found that even on our brand new computers, they are still not capable of quickly rendering the newly added transparency effect when moving sticky notes in Acrobat 9. Anytime a user wishes to reposition the detail box of an Acrobat Comment, they must wait for the effect to render and chase the mouse around the screen.

Though searching through the software, I cannot find a way to disable the effect to resurrect the simple rectangle that was used in Acrobat 8.

I also put in 2 request to Adobe support as of today. FYI, we are reviewing 32page PDFx1/a documents (<25MB) and it happens with 1 sticky or 100 stickies just the same. The computers are new iMac 2GHz dual core with 2GB and 4GB configurations (all are affected).

Tuesday, July 22, 2008

Removing the alenaprosti worm From your Infected Files on Network Solution's Host

I suppose giving light on how one needs to clean their files of the infection is in order.

First, check your .htaccess for a rewrite rule directing requests of "alenaprosti" to a folder on your virtual host. Mine was a folder labeled "29". Delete this folder and all contents, and remove the rewrite rule from your .htaccess file.

Next, check all index.html[php][cgi][shtml][etc...] files for code matching the regular expression <ul style=\"display:none;\">.*</ul> and delete it from each file.

Now, do a Google site search for "alenaprosti" on your domain. For example, search the following: "alenaprosti site:mydomain.com". Using each of the entries, visit the Google Webmasters site at www.google.com/webmasters/ and submit URL removals for each of the results. It wouldn't hurt to add a disallow for "alenaprosti" in your robots.txt file, either.

This should work in most instances, but until Network Solutions fixes their security leak, be prepared to do it all over again in a month.

Network Solutions Hosting Server has a Worm

After many recent back-and-forth emails with Network Solution's Customer no-Service Department, it became clear to me that one of their main hosting servers is infected with a worm and HUNDREDS of sites are now infected as a result.

Go ahead, do the search in Google for "alenaprosti". You'll be surprised at the number of infected sites.

Network Solutions still has the nerve to tell me my "permissions settings are incorrect" when in fact it is their server that is infected. I sent them a list of about the first 70 sites from the Google results, of which 99% were on the server with IP 205.178.145.65.

Are you one of the hundreds affected. I hope so - then we can revolt! I smell a lawsuit cooking already.

Digg It!Digg It!