mirror of
https://github.com/Terranom674/Piwigo_Bratonien_Tools.git
synced 2026-11-05 23:32:16 +00:00
Compare commits
3
Commits
774c82ab68
...
c9e8cee89e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9e8cee89e | ||
|
|
77981a4e05 | ||
|
|
875832b73e |
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: Bratonien Tools
|
||||
Version: 0.9.5.1
|
||||
Version: 0.9.5.2
|
||||
Description: Erweiterbare Administrationswerkzeuge fuer die Bratonien-Piwigo-Installation.
|
||||
Plugin URI: https://github.com/Terranom674/Piwigo_Bratonien_Tools
|
||||
Author: Bratonien
|
||||
|
||||
@@ -21,16 +21,15 @@ function user_scope_path_has_segment($path, $segment)
|
||||
return false;
|
||||
}
|
||||
|
||||
function user_scope_candidate($mount, $prefix, $accessUser)
|
||||
function user_scope_candidate($root, $accessUser, $sourcePrefix = '')
|
||||
{
|
||||
$mount = rtrim((string)$mount, '/');
|
||||
$prefix = trim((string)$prefix, '/');
|
||||
if ($mount === '' || $mount[0] !== '/') return null;
|
||||
$root = $mount.($prefix !== '' ? '/'.$prefix : '');
|
||||
$root = rtrim((string)$root, '/');
|
||||
$sourcePrefix = trim((string)$sourcePrefix, '/');
|
||||
if ($root === '' || $root[0] !== '/') return null;
|
||||
if (!is_dir($root) || !is_readable($root)) return null;
|
||||
$real = realpath($root);
|
||||
if ($real === false || !user_scope_path_has_segment($real, $accessUser)) return null;
|
||||
return array('local_mount'=>$mount, 'source_prefix'=>$prefix, 'root'=>$real);
|
||||
return array('local_mount'=>$real, 'source_prefix'=>$sourcePrefix, 'root'=>$real);
|
||||
}
|
||||
|
||||
function user_scope_storage(array $storage, $accessUser)
|
||||
@@ -45,27 +44,52 @@ function user_scope_storage(array $storage, $accessUser)
|
||||
$candidates[$candidate['root']] = $candidate;
|
||||
};
|
||||
|
||||
$add(user_scope_candidate($mount, $prefix, $accessUser));
|
||||
// Bereits benutzerspezifisch gespeicherter Mount.
|
||||
$add(user_scope_candidate($mount, $accessUser, $prefix));
|
||||
|
||||
// Nextcloud Home-Storage liegt normalerweise unter <data>/<uid>/files.
|
||||
// Wir akzeptieren ausschließlich Pfade, die die konkrete UID als eigenes
|
||||
// Pfadsegment enthalten. Ein generischer Daten-Mount wird nie freigegeben.
|
||||
if ($mount !== '')
|
||||
{
|
||||
$add(user_scope_candidate(dirname($mount).'/'.$accessUser, $prefix, $accessUser));
|
||||
$add(user_scope_candidate($mount.'/'.$accessUser, $prefix, $accessUser));
|
||||
$bases = array(
|
||||
$mount,
|
||||
dirname($mount),
|
||||
dirname(dirname($mount)),
|
||||
);
|
||||
foreach (array_unique($bases) as $base)
|
||||
{
|
||||
$add(user_scope_candidate(rtrim($base, '/').'/'.$accessUser.'/files', $accessUser, ''));
|
||||
$add(user_scope_candidate(rtrim($base, '/').'/'.$accessUser, $accessUser, 'files'));
|
||||
}
|
||||
}
|
||||
|
||||
// Falls der alte source_prefix bereits die UID enthaelt, kann daraus ein
|
||||
// eindeutiger benutzerspezifischer Root abgeleitet werden.
|
||||
if ($prefix !== '')
|
||||
{
|
||||
$parts = explode('/', $prefix);
|
||||
if ($parts && (string)$parts[0] !== (string)$accessUser)
|
||||
$userPos = array_search($accessUser, $parts, true);
|
||||
if ($userPos !== false)
|
||||
{
|
||||
array_shift($parts);
|
||||
$rest = implode('/', $parts);
|
||||
$add(user_scope_candidate($mount.'/'.$accessUser, $rest, $accessUser));
|
||||
$before = array_slice($parts, 0, $userPos);
|
||||
$after = array_slice($parts, $userPos + 1);
|
||||
$base = $mount;
|
||||
if ($before) $base .= '/'.implode('/', $before);
|
||||
$root = $base.'/'.$accessUser;
|
||||
if (isset($after[0]) && $after[0] === 'files')
|
||||
{
|
||||
$root .= '/files';
|
||||
array_shift($after);
|
||||
}
|
||||
$add(user_scope_candidate($root, $accessUser, implode('/', $after)));
|
||||
}
|
||||
}
|
||||
|
||||
if (count($candidates) !== 1)
|
||||
{
|
||||
user_scope_fail('Der lokale Dateistamm für Nextcloud-Benutzer '.$accessUser.' konnte nicht eindeutig bestimmt werden. Die Verbindung wird aus Sicherheitsgründen nicht gestartet.');
|
||||
$count = count($candidates);
|
||||
user_scope_fail('Der lokale Dateistamm für Nextcloud-Benutzer '.$accessUser.' konnte nicht eindeutig bestimmt werden ('.$count.' passende Pfade). Die Verbindung wird aus Sicherheitsgründen nicht gestartet.');
|
||||
}
|
||||
|
||||
$resolved = reset($candidates);
|
||||
|
||||
+12
-1
@@ -93,9 +93,20 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
function lastResultValueNode(){
|
||||
var notes=[].slice.call(section.querySelectorAll('.bratonien-base-note'));
|
||||
for(var i=0;i<notes.length;i++){
|
||||
var text=(notes[i].textContent||'').trim();
|
||||
if(text.indexOf('Letztes Ergebnis:')===0){
|
||||
return notes[i].querySelector('strong');
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
var lastRunNode=valueNodeForLabel('Letzter Lauf');
|
||||
var nextRunNode=valueNodeForLabel('Nächster Lauf');
|
||||
var lastResultNode=valueNodeForLabel('Letztes Ergebnis');
|
||||
var lastResultNode=lastResultValueNode();
|
||||
|
||||
function poll(){
|
||||
fetch(endpoint+'?_='+Date.now(),{credentials:'same-origin',cache:'no-store'})
|
||||
|
||||
Reference in new issue
Block a user