Skip to content

Commit

Permalink
v6.2-a1: * 🌱**Crawler** Cralwer hit/miss filter. (#328853)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hai Zheng committed Jan 30, 2024
1 parent 72d7d75 commit 6eaf10c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
38 changes: 36 additions & 2 deletions src/crawler-map.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,36 @@ public function list_map($limit, $offset = false)
$offset = Utility::pagination($total, $limit, true);
}

$type = Router::verify_type();

$where = '';
if (!empty($_POST['kw'])) {
$q = "SELECT * FROM `$this->_tb` WHERE url LIKE %s ORDER BY id LIMIT %d, %d";
$q = "SELECT * FROM `$this->_tb` WHERE url LIKE %s";
if ($type == 'hit') {
$q .= " AND res LIKE '%H%'";
}
if ($type == 'miss') {
$q .= " AND res LIKE '%M%'";
}
if ($type == 'blacklisted') {
$q .= " AND res LIKE '%B%'";
}
$q .= ' ORDER BY id LIMIT %d, %d';
$where = '%' . $wpdb->esc_like($_POST['kw']) . '%';
return $wpdb->get_results($wpdb->prepare($q, $where, $offset, $limit), ARRAY_A);
}

$q = "SELECT * FROM `$this->_tb` ORDER BY id LIMIT %d, %d";
$q = "SELECT * FROM `$this->_tb`";
if ($type == 'hit') {
$q .= " WHERE res LIKE '%H%'";
}
if ($type == 'miss') {
$q .= " WHERE res LIKE '%M%'";
}
if ($type == 'blacklisted') {
$q .= " WHERE res LIKE '%B%'";
}
$q .= ' ORDER BY id LIMIT %d, %d';
// self::debug("q=$q offset=$offset, limit=$limit");
return $wpdb->get_results($wpdb->prepare($q, $offset, $limit), ARRAY_A);
}
Expand All @@ -322,6 +344,18 @@ public function count_map()
}

$q = "SELECT COUNT(*) FROM `$this->_tb`";

$type = Router::verify_type();
if ($type == 'hit') {
$q .= " WHERE res LIKE '%H%'";
}
if ($type == 'miss') {
$q .= " WHERE res LIKE '%M%'";
}
if ($type == 'blacklisted') {
$q .= " WHERE res LIKE '%B%'";
}

return $wpdb->get_var($q);
}

Expand Down
9 changes: 9 additions & 0 deletions tpl/crawler/map.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
$pagination = Utility::pagination($count, 30);

?>

<p class="litespeed-right">
<a href="<?php echo Utility::build_url(Router::ACTION_CRAWLER, Crawler::TYPE_EMPTY); ?>" class="button litespeed-btn-warning">
<?php echo __('Clean Crawler Map', 'litespeed-cache'); ?>
Expand Down Expand Up @@ -45,6 +46,14 @@
</form>
</div>

<div class="">

<a style="padding-right:10px;" href="<?php echo admin_url('admin.php?page=litespeed-crawler&' . Router::TYPE . '=hit'); ?>"><?php echo __('Cache Hit', 'litespeed-cache'); ?></a>
<a style="padding-right:10px;" href="<?php echo admin_url('admin.php?page=litespeed-crawler&' . Router::TYPE . '=miss'); ?>"><?php echo __('Cache Miss', 'litespeed-cache'); ?></a>
<a style="padding-right:10px;" href="<?php echo admin_url('admin.php?page=litespeed-crawler&' . Router::TYPE . '=blacklisted'); ?>"><?php echo __('Blocklisted', 'litespeed-cache'); ?></a>

</div>

<div class="">
<?php echo $pagination; ?>
</div>
Expand Down

0 comments on commit 6eaf10c

Please sign in to comment.