forked from leftypol/leftypol
Compare commits
1 commit
config
...
notes-quer
Author | SHA1 | Date | |
---|---|---|---|
158f697c88 |
1 changed files with 15 additions and 8 deletions
|
@ -4,7 +4,7 @@
|
||||||
*/
|
*/
|
||||||
use Vichan\Context;
|
use Vichan\Context;
|
||||||
use Vichan\Data\ReportQueries;
|
use Vichan\Data\ReportQueries;
|
||||||
use Vichan\Functions\Format;
|
use Vichan\Data\Driver\CacheDriver;
|
||||||
use Vichan\Functions\Net;
|
use Vichan\Functions\Net;
|
||||||
|
|
||||||
use function Vichan\Functions\Net\decode_cursor;
|
use function Vichan\Functions\Net\decode_cursor;
|
||||||
|
@ -860,11 +860,15 @@ function mod_ip_remove_note(Context $ctx, $ip, $id) {
|
||||||
if (filter_var($ip, FILTER_VALIDATE_IP) === false)
|
if (filter_var($ip, FILTER_VALIDATE_IP) === false)
|
||||||
error("Invalid IP address.");
|
error("Invalid IP address.");
|
||||||
|
|
||||||
|
$cache = $ctx->get(CacheDriver::class);
|
||||||
|
|
||||||
$query = prepare('DELETE FROM ``ip_notes`` WHERE `ip` = :ip AND `id` = :id');
|
$query = prepare('DELETE FROM ``ip_notes`` WHERE `ip` = :ip AND `id` = :id');
|
||||||
$query->bindValue(':ip', $ip);
|
$query->bindValue(':ip', $ip);
|
||||||
$query->bindValue(':id', $id);
|
$query->bindValue(':id', $id);
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
|
|
||||||
|
$cache->delete("mod_page_ip_view_notes_$ip");
|
||||||
|
|
||||||
modLog("Removed a note for <a href=\"?/IP/{$ip}\">{$ip}</a>");
|
modLog("Removed a note for <a href=\"?/IP/{$ip}\">{$ip}</a>");
|
||||||
|
|
||||||
header('Location: ?/IP/' . $ip . '#notes', true, $config['redirect_http']);
|
header('Location: ?/IP/' . $ip . '#notes', true, $config['redirect_http']);
|
||||||
|
@ -903,7 +907,8 @@ function mod_ip(Context $ctx, $ip, string $encoded_cursor = '') {
|
||||||
$query->bindValue(':body', $_POST['note']);
|
$query->bindValue(':body', $_POST['note']);
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
|
|
||||||
Cache::delete("mod_page_ip_view_notes_$ip");
|
$cache = $ctx->get(CacheDriver::class);
|
||||||
|
$cache->delete("mod_page_ip_view_notes_$ip");
|
||||||
|
|
||||||
modLog("Added a note for <a href=\"?/IP/{$ip}\">{$ip}</a>");
|
modLog("Added a note for <a href=\"?/IP/{$ip}\">{$ip}</a>");
|
||||||
|
|
||||||
|
@ -1025,25 +1030,27 @@ function mod_ip(Context $ctx, $ip, string $encoded_cursor = '') {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasPermission($config['mod']['view_notes'])) {
|
if (hasPermission($config['mod']['view_notes'])) {
|
||||||
$ret = Cache::get("mod_page_ip_view_notes_$ip");
|
$cache = $ctx->get(CacheDriver::class);
|
||||||
if (!$ret) {
|
$ret = $cache->get("mod_page_ip_view_notes_$ip");
|
||||||
|
if ($ret === null) {
|
||||||
$query = prepare("SELECT ``ip_notes``.*, `username` FROM ``ip_notes`` LEFT JOIN ``mods`` ON `mod` = ``mods``.`id` WHERE `ip` = :ip ORDER BY `time` DESC");
|
$query = prepare("SELECT ``ip_notes``.*, `username` FROM ``ip_notes`` LEFT JOIN ``mods`` ON `mod` = ``mods``.`id` WHERE `ip` = :ip ORDER BY `time` DESC");
|
||||||
$query->bindValue(':ip', $ip);
|
$query->bindValue(':ip', $ip);
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
$ret = $query->fetchAll(PDO::FETCH_ASSOC);
|
$ret = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||||
Cache::set("mod_page_ip_view_notes_$ip", $ret, 900);
|
$cache->set("mod_page_ip_view_notes_$ip", $ret, 900);
|
||||||
}
|
}
|
||||||
$args['notes'] = $ret;
|
$args['notes'] = $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasPermission($config['mod']['modlog_ip'])) {
|
if (hasPermission($config['mod']['modlog_ip'])) {
|
||||||
$ret = Cache::get("mod_page_ip_modlog_ip_$ip");
|
$cache = $ctx->get(CacheDriver::class);
|
||||||
if (!$ret) {
|
$ret = $cache->get("mod_page_ip_modlog_ip_$ip");
|
||||||
|
if ($ret === null) {
|
||||||
$query = prepare("SELECT `username`, `mod`, `ip`, `board`, `time`, `text` FROM ``modlogs`` LEFT JOIN ``mods`` ON `mod` = ``mods``.`id` WHERE `text` LIKE :search ORDER BY `time` DESC LIMIT 50");
|
$query = prepare("SELECT `username`, `mod`, `ip`, `board`, `time`, `text` FROM ``modlogs`` LEFT JOIN ``mods`` ON `mod` = ``mods``.`id` WHERE `text` LIKE :search ORDER BY `time` DESC LIMIT 50");
|
||||||
$query->bindValue(':search', '%' . $ip . '%');
|
$query->bindValue(':search', '%' . $ip . '%');
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
$ret = $query->fetchAll(PDO::FETCH_ASSOC);
|
$ret = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||||
Cache::set("mod_page_ip_modlog_ip_$ip", $ret, 900);
|
$cache->set("mod_page_ip_modlog_ip_$ip", $ret, 900);
|
||||||
}
|
}
|
||||||
$args['logs'] = $ret;
|
$args['logs'] = $ret;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue