function tkzy_get_recent_comments($limit = 10)
{
    global $wpdb, $tablecomments, $tableposts;
    global $siteurl, $blogfilename;
    $lcomments = $wpdb->get_results("SELECT ID, post_title, post_date, \n     comment_ID, comment_author, comment_author_url, comment_author_email, comment_date, comment_content \n     FROM {$tableposts}, {$tablecomments} WHERE {$tableposts}.ID={$tablecomments}.comment_post_ID \n     ORDER BY {$tablecomments}.comment_date DESC LIMIT {$limit}");
    $output = '';
    function sort_comment_by_date($a, $b)
    {
        if ($b->ID == $a->ID) {
            return mysql2date('U', $a->comment_date) - mysql2date('U', $b->comment_date);
        }
        return mysql2date('U', $b->post_date) - mysql2date('U', $a->post_date);
    }
    if ($lcomments) {
        usort($lcomments, "sort_comment_by_date");
    }
    $new_post_ID = -1;
    if ($lcomments) {
        foreach ($lcomments as $lcomment) {
            if ($lcomment->ID != $new_post_ID) {
                // next post
                if ($new_post_ID != -1) {
                    $output .= "\t</ul>\n</li>\n";
                }
                $post_title = stripslashes($lcomment->post_title);
                $permalink = "{$siteurl}/{$blogfilename}?p={$lcomment->ID}&amp;c=1";
                $output .= "<li>";
                $output .= "<a href=\"{$permalink}\">{$post_title}</a>\n";
                $output .= "\t<ul>\n";
                $new_post_ID = $lcomment->ID;
            }
            $comment_date = $lcomment->comment_date;
            if (time() - mysql2date('U', $comment_date) < 60 * 60 * 24) {
                # within 24 hours
                $comment_date = mysql2date('H:i', $comment_date);
            } else {
                $comment_date = mysql2date('m/d', $comment_date);
            }
            $output .= "\t\t<li style=\"list-style: none;\"><span style=\"font-size:90%;\" class=\"comment_date\">{$comment_date} </span>" . "<span class=\"comment_author\">" . tkzy_get_comment_author_link($lcomment, 25) . "</span></li>\n";
            if (preg_match('|<trackback />|', $lcomment->comment_content)) {
                $type = '[TrackBack]';
            } elseif (preg_match('|<pingback />|', $lcomment->comment_content)) {
                $type = '[Ping]';
            } else {
                $type = '[Comment]';
            }
            $output .= "<span style=\"font-size:70%\"> - {$type}</span>";
        }
    }
    $output .= "\t</ul>\n</li>\n";
    return $output;
}
 function tkzy_get_recent_comments($limit = 10, $cat_date = 1, $show_type = 1)
 {
     $comment_lenth = 30;
     $request = "SELECT ID, post_title, post_date, \n\t\tcomment_ID, comment_author, comment_author_url, comment_author_email, comment_date, comment_content \n\t\tFROM " . wp_table('posts') . ", " . wp_table('comments') . " WHERE " . wp_table('posts') . ".ID=" . wp_table('comments') . ".comment_post_ID AND " . wp_table('comments') . ".comment_approved='1'";
     if (get_xoops_option(wp_mod(), 'wp_use_xoops_comments') == 1) {
         $request .= "AND (comment_content like '<trackback />%' OR comment_content like '<pingkback />%') ";
     }
     $request .= " ORDER BY " . wp_table('comments') . ".comment_date DESC LIMIT {$limit}";
     $lcomments = $GLOBALS['wpdb']->get_results($request);
     $output = '';
     if ($lcomments) {
         usort($lcomments, "sort_comment_by_date");
     }
     $new_post_ID = -1;
     if ($lcomments) {
         $output .= "<ul class='wpBlockList'>";
         foreach ($lcomments as $lcomment) {
             if ($lcomment->ID != $new_post_ID) {
                 // next post
                 if ($new_post_ID != -1) {
                     $output .= "\t</ul>\n</li>\n";
                 }
                 $post_title = stripslashes($lcomment->post_title);
                 if (trim($post_title) == "") {
                     $post_title = _WP_POST_NOTITLE;
                 }
                 $comment_content = strip_tags($lcomment->comment_content);
                 $comment_content = stripslashes($comment_content);
                 if (function_exists('mb_substr')) {
                     $comment_excerpt = mb_substr($comment_content, 0, $comment_lenth);
                 } else {
                     $comment_excerpt = substr($comment_content, 0, $comment_lenth);
                 }
                 $permalink = wp_siteurl() . "/index.php?p={$lcomment->ID}&amp;c=1";
                 $output .= "<li>";
                 $output .= "<span class='comment-title'><a href=\"{$permalink}\">{$post_title}</a></span>\n";
                 $output .= "\t<ul class=\"children\" style=\"list-style-type: none;\">\n";
                 $new_post_ID = $lcomment->ID;
             }
             $output .= "\t\t<li>";
             if ($cat_date) {
                 $comment_date = $lcomment->comment_date;
                 if (time() - mysql2date('U', $comment_date) < 60 * 60 * 24) {
                     # within 24 hours
                     $comment_date = mysql2date('H:i', $comment_date);
                 } else {
                     $comment_date = mysql2date('m/d', $comment_date);
                 }
                 $output .= "<span class=\"post-date\">{$comment_date}</span> : ";
             }
             $output .= "<span class=\"comment_author\">" . tkzy_get_comment_author_link($lcomment, 25) . "</span></li>\n";
             if (preg_match('|<trackback />|', $lcomment->comment_content)) {
                 $type = '[TrackBack]';
             } elseif (preg_match('|<pingback />|', $lcomment->comment_content)) {
                 $type = '[Ping]';
             } else {
                 $type = '[Comment]';
             }
             if ($show_type) {
                 $output .= "<span style=\"font-size:90%\"> - {$type}</span>";
             }
         }
     }
     $output .= "\t</ul>\n</li>\n</ul>\n";
     return $output;
 }
    function tkzy_get_recent_comments($limit = 10, $cat_date = 1, $show_type = 1)
    {
        $comment_lenth = 30;
        $request = 'SELECT ID, post_title, post_date, 
		comment_ID, comment_author, comment_author_url, comment_author_email, comment_date, comment_content 
		FROM ' . wp_table('posts') . ', ' . wp_table('comments') . ' WHERE ' . wp_table('posts') . '.ID=' . wp_table('comments') . '.comment_post_ID AND ' . wp_table('comments') . '.comment_approved=\'1\'';
        if (get_xoops_option(wp_mod(), 'wp_use_xoops_comments') == 1) {
            $request .= ' AND (comment_content like \'<trackback />%\' OR comment_content like \'<pingkback />%\') ';
        }
        $request .= ' ORDER BY ' . wp_table('comments') . '.comment_date DESC LIMIT ' . $limit;
        $lcomments = $GLOBALS['wpdb']->get_results($request);
        $output = '';
        if ($lcomments) {
            usort($lcomments, 'sort_comment_by_date');
        }
        $new_post_ID = -1;
        if ($lcomments) {
            $output .= '<ul class="wpBlockList">';
            foreach ($lcomments as $lcomment) {
                if ($lcomment->ID != $new_post_ID) {
                    // next post
                    if ($new_post_ID != -1) {
                        $output .= '</ul></li>';
                    }
                    $post_title = stripslashes($lcomment->post_title);
                    if (trim($post_title) == "") {
                        $post_title = _WP_POST_NOTITLE;
                    }
                    $comment_content = strip_tags($lcomment->comment_content);
                    $comment_content = stripslashes($comment_content);
                    if (function_exists('mb_substr')) {
                        $comment_excerpt = mb_substr($comment_content, 0, $comment_lenth);
                    } else {
                        $comment_excerpt = substr($comment_content, 0, $comment_lenth);
                    }
                    $permalink = wp_siteurl() . '/index.php?p=' . $lcomment->ID . '&amp;c=1';
                    $output .= '<li>';
                    $output .= '<span class="comment-title"><a href="' . $permalink . '">' . $post_title . '</a></span>';
                    $output .= '<ul class="children" style="list-style-type: none;">';
                    $new_post_ID = $lcomment->ID;
                }
                $output .= "\t\t<li>";
                if ($cat_date) {
                    $comment_date = $lcomment->comment_date;
                    if (time() - mysql2date('U', $comment_date) < 60 * 60 * 24) {
                        # within 24 hours
                        $comment_date = mysql2date('H:i', $comment_date);
                    } else {
                        $comment_date = mysql2date('m/d', $comment_date);
                    }
                    $output .= '<span class="post-date">' . $comment_date . '</span> : ';
                }
                $output .= '<span class="comment_author">' . tkzy_get_comment_author_link($lcomment, 25) . '</span></li>';
                if (preg_match('|<trackback />|', $lcomment->comment_content)) {
                    $type = '[TrackBack]';
                } elseif (preg_match('|<pingback />|', $lcomment->comment_content)) {
                    $type = '[Ping]';
                } else {
                    $type = '[Comment]';
                }
                if ($show_type) {
                    $output .= '<span style="font-size:90%"> - ' . $type . '</span>';
                }
            }
        }
        $output .= '</ul></li></ul>';
        return $output;
    }
 function tkzy_get_recent_comments($limit = 10, $cat_date = 1, $show_type = 1)
 {
     global $wpdb, $wp_id;
     global $siteurl;
     $comment_lenth = 30;
     $lcomments = $wpdb->get_results("SELECT ID, post_title, post_date, \n\t\tcomment_ID, comment_author, comment_author_url, comment_author_email, comment_date, comment_content \n\t\tFROM {$wpdb->posts[$wp_id]}, {$wpdb->comments[$wp_id]} WHERE {$wpdb->posts[$wp_id]}.ID={$wpdb->comments[$wp_id]}.comment_post_ID AND {$wpdb->comments[$wp_id]}.comment_approved='1'\n\t\tORDER BY {$wpdb->comments[$wp_id]}.comment_date DESC LIMIT {$limit}");
     $output = '';
     if ($lcomments) {
         usort($lcomments, "sort_comment_by_date");
     }
     $new_post_ID = -1;
     if ($lcomments) {
         $output .= "<ul class='wpBlockList'>";
         foreach ($lcomments as $lcomment) {
             if ($lcomment->ID != $new_post_ID) {
                 // next post
                 if ($new_post_ID != -1) {
                     $output .= "\t</ul>\n</li>\n";
                 }
                 $post_title = stripslashes($lcomment->post_title);
                 if (trim($post_title) == "") {
                     $post_title = _WP_POST_NOTITLE;
                 }
                 $comment_content = strip_tags($lcomment->comment_content);
                 $comment_content = stripslashes($comment_content);
                 if (function_exists('mb_substr')) {
                     $comment_excerpt = mb_substr($comment_content, 0, $comment_lenth);
                 } else {
                     $comment_excerpt = substr($comment_content, 0, $comment_lenth);
                 }
                 $permalink = "{$siteurl}/index.php?p={$lcomment->ID}&amp;c=1";
                 $output .= "<li>";
                 $output .= "<span class='comment-title'><a href=\"{$permalink}\">{$post_title}</a></span>\n";
                 $output .= "\t<ul class=\"children\" style=\"list-style-type: none;\">\n";
                 $new_post_ID = $lcomment->ID;
             }
             $output .= "\t\t<li>";
             if ($cat_date) {
                 $comment_date = $lcomment->comment_date;
                 if (time() - mysql2date('U', $comment_date) < 60 * 60 * 24) {
                     # within 24 hours
                     $comment_date = mysql2date('H:i', $comment_date);
                 } else {
                     $comment_date = mysql2date('m/d', $comment_date);
                 }
                 $output .= "<span class=\"post-date\">{$comment_date}</span> : ";
             }
             $output .= "<span class=\"comment_author\">" . tkzy_get_comment_author_link($lcomment, 25) . "</span></li>\n";
             if (preg_match('|<trackback />|', $lcomment->comment_content)) {
                 $type = '[TrackBack]';
             } elseif (preg_match('|<pingback />|', $lcomment->comment_content)) {
                 $type = '[Ping]';
             } else {
                 $type = '[Comment]';
             }
             if ($show_type) {
                 $output .= "<span style=\"font-size:90%\"> - {$type}</span>";
             }
         }
     }
     $output .= "\t</ul>\n</li>\n</ul>\n";
     return $output;
 }