mirror of
https://github.com/kokororin/typecho-plugin-Access.git
synced 2026-08-19 10:23:27 +08:00
feat: auto escape sql like when switch fuzzy mode
This commit is contained in:
@@ -48,13 +48,13 @@ class Access_Logs {
|
||||
if ($ua !== $empty) {
|
||||
$query->where('ua' . $compare, $ua);
|
||||
}
|
||||
if ($cid !== $empty) {
|
||||
if ($cid !== '') {
|
||||
$query->where('content_id' . $compare, $cid);
|
||||
}
|
||||
if ($path !== $empty) {
|
||||
$query->where('path' . $compare, $path);
|
||||
}
|
||||
if ($robot !== $empty) {
|
||||
if ($robot !== '') {
|
||||
$query->where('robot = ?', $robot);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ $(document).ready(function () {
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
if (!silent) {
|
||||
$('body').loadingModal('hide');
|
||||
$('.typecho-list').loadingModal('hide');
|
||||
}
|
||||
swal({
|
||||
icon: "error",
|
||||
@@ -228,6 +228,7 @@ $(document).ready(function () {
|
||||
}
|
||||
|
||||
$('button[data-action="filter-apply"]').click(function() {
|
||||
setPageNum(1);
|
||||
fetchLogs();
|
||||
hideFilters();
|
||||
});
|
||||
@@ -243,6 +244,31 @@ $(document).ready(function () {
|
||||
toggleFilters();
|
||||
});
|
||||
|
||||
$('[name="filter-fuzzy"]').change(function(e) {
|
||||
var filters = getFilters();
|
||||
var inputKeys = ['ua', 'ip', 'path'];
|
||||
if (e.target.value === '1') {
|
||||
$(inputKeys).each(function(_, k) {
|
||||
if (filters[k] === '') {
|
||||
filters[k] = '%';
|
||||
} else {
|
||||
// MySQL escape: https://dev.mysql.com/doc/refman/8.0/en/string-comparison-functions.html
|
||||
filters[k] = filters[k].replace(/[%_]/gu, function(s) { return '\\' + s; });
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$(inputKeys).each(function(_, k) {
|
||||
if (filters[k] === '%') {
|
||||
filters[k] = '';
|
||||
} else {
|
||||
// MySQL escape: https://dev.mysql.com/doc/refman/8.0/en/string-comparison-functions.html
|
||||
filters[k] = filters[k].replace(/\\[%_]/gu, function(s) { return s.substring(1); });
|
||||
}
|
||||
});
|
||||
}
|
||||
setFilters(filters);
|
||||
});
|
||||
|
||||
$('input[name="page-jump"]').on('keypress', function(e) {
|
||||
if (e.which == 13) {
|
||||
setPageNum(e.target.value);
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<div class="typecho-access-logs-filter-item">
|
||||
<label class="typecho-access-logs-filter-item__label">访客类型</label>
|
||||
<select class="typecho-access-logs-filter-item__content" name="filter-robot">
|
||||
<option value="0"><?php _e('默认(仅人类)'); ?></option>
|
||||
<option value="0"><?php _e('仅人类'); ?></option>
|
||||
<option value="1"><?php _e('仅爬虫'); ?></option>
|
||||
<option value=""><?php _e('所有'); ?></option>
|
||||
</select>
|
||||
|
||||
Reference in New Issue
Block a user