forked from leftypol/leftypol
pages.php: use LogDriver
This commit is contained in:
parent
665e3d339a
commit
5b4d1b7f4c
1 changed files with 14 additions and 10 deletions
|
@ -4,16 +4,19 @@
|
|||
*/
|
||||
use Vichan\Context;
|
||||
use Vichan\Data\{IpNoteQueries, UserPostQueries, ReportQueries};
|
||||
use Vichan\Data\Driver\LogDriver;
|
||||
use Vichan\Functions\Net;
|
||||
|
||||
defined('TINYBOARD') or exit;
|
||||
|
||||
function _link_or_copy(string $target, string $link): bool {
|
||||
if (!link($target, $link)) {
|
||||
error_log("Failed to link() $target to $link. FAlling back to copy()");
|
||||
return copy($target, $link);
|
||||
}
|
||||
return true;
|
||||
function _link_or_copy_factory(Context $ctx): callable {
|
||||
return function(string $target, string $link) use ($ctx) {
|
||||
if (!\link($target, $link)) {
|
||||
$ctx->get(LogDriver::class)->log(LogDriver::NOTICE, "Failed to link() $target to $link. FAlling back to copy()");
|
||||
return \copy($target, $link);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
function mod_page($title, $template, $args, $subtitle = false) {
|
||||
|
@ -54,8 +57,7 @@ function mod_login(Context $ctx, $redirect = false) {
|
|||
if (!isset($_POST['username'], $_POST['password']) || $_POST['username'] == '' || $_POST['password'] == '') {
|
||||
$args['error'] = $config['error']['invalid'];
|
||||
} elseif (!login($_POST['username'], $_POST['password'])) {
|
||||
if ($config['syslog'])
|
||||
_syslog(LOG_WARNING, 'Unauthorized login attempt!');
|
||||
$ctx->get(LogDriver::class)->log(LogDriver::INFO, 'Unauthorized login attempt!');
|
||||
|
||||
$args['error'] = $config['error']['invalid'];
|
||||
} else {
|
||||
|
@ -1489,8 +1491,9 @@ function mod_move(Context $ctx, $originBoard, $postID) {
|
|||
if ($targetBoard === $originBoard)
|
||||
error(_('Target and source board are the same.'));
|
||||
|
||||
$_link_or_copy = _link_or_copy_factory($ctx);
|
||||
// link() if leaving a shadow thread behind; else, rename().
|
||||
$clone = $shadow ? '_link_or_copy' : 'rename';
|
||||
$clone = $shadow ? $_link_or_copy : 'rename';
|
||||
|
||||
// indicate that the post is a thread
|
||||
$post['op'] = true;
|
||||
|
@ -1784,7 +1787,8 @@ function mod_merge(Context $ctx, $originBoard, $postID) {
|
|||
$op = $post;
|
||||
$op['id'] = $newID;
|
||||
|
||||
$clone = $shadow ? '_link_or_copy' : 'rename';
|
||||
$_link_or_copy = _link_or_copy_factory($ctx);
|
||||
$clone = $shadow ? $_link_or_copy : 'rename';
|
||||
|
||||
if ($post['has_file']) {
|
||||
// copy image
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue