mirror of
https://github.com/Terranom674/Piwigo_Bratonien_Tools.git
synced 2026-09-20 19:13:19 +00:00
Compare commits
3 Commits
774c82ab68
...
c9e8cee89e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9e8cee89e | ||
|
|
77981a4e05 | ||
|
|
875832b73e |
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
Plugin Name: Bratonien Tools
|
Plugin Name: Bratonien Tools
|
||||||
Version: 0.9.5.1
|
Version: 0.9.5.2
|
||||||
Description: Erweiterbare Administrationswerkzeuge fuer die Bratonien-Piwigo-Installation.
|
Description: Erweiterbare Administrationswerkzeuge fuer die Bratonien-Piwigo-Installation.
|
||||||
Plugin URI: https://github.com/Terranom674/Piwigo_Bratonien_Tools
|
Plugin URI: https://github.com/Terranom674/Piwigo_Bratonien_Tools
|
||||||
Author: Bratonien
|
Author: Bratonien
|
||||||
|
|||||||
@@ -21,16 +21,15 @@ function user_scope_path_has_segment($path, $segment)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_scope_candidate($mount, $prefix, $accessUser)
|
function user_scope_candidate($root, $accessUser, $sourcePrefix = '')
|
||||||
{
|
{
|
||||||
$mount = rtrim((string)$mount, '/');
|
$root = rtrim((string)$root, '/');
|
||||||
$prefix = trim((string)$prefix, '/');
|
$sourcePrefix = trim((string)$sourcePrefix, '/');
|
||||||
if ($mount === '' || $mount[0] !== '/') return null;
|
if ($root === '' || $root[0] !== '/') return null;
|
||||||
$root = $mount.($prefix !== '' ? '/'.$prefix : '');
|
|
||||||
if (!is_dir($root) || !is_readable($root)) return null;
|
if (!is_dir($root) || !is_readable($root)) return null;
|
||||||
$real = realpath($root);
|
$real = realpath($root);
|
||||||
if ($real === false || !user_scope_path_has_segment($real, $accessUser)) return null;
|
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)
|
function user_scope_storage(array $storage, $accessUser)
|
||||||
@@ -45,27 +44,52 @@ function user_scope_storage(array $storage, $accessUser)
|
|||||||
$candidates[$candidate['root']] = $candidate;
|
$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 !== '')
|
if ($mount !== '')
|
||||||
{
|
{
|
||||||
$add(user_scope_candidate(dirname($mount).'/'.$accessUser, $prefix, $accessUser));
|
$bases = array(
|
||||||
$add(user_scope_candidate($mount.'/'.$accessUser, $prefix, $accessUser));
|
$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 !== '')
|
if ($prefix !== '')
|
||||||
{
|
{
|
||||||
$parts = explode('/', $prefix);
|
$parts = explode('/', $prefix);
|
||||||
if ($parts && (string)$parts[0] !== (string)$accessUser)
|
$userPos = array_search($accessUser, $parts, true);
|
||||||
|
if ($userPos !== false)
|
||||||
{
|
{
|
||||||
array_shift($parts);
|
$before = array_slice($parts, 0, $userPos);
|
||||||
$rest = implode('/', $parts);
|
$after = array_slice($parts, $userPos + 1);
|
||||||
$add(user_scope_candidate($mount.'/'.$accessUser, $rest, $accessUser));
|
$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)
|
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);
|
$resolved = reset($candidates);
|
||||||
|
|||||||
@@ -93,9 +93,20 @@
|
|||||||
return null;
|
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 lastRunNode=valueNodeForLabel('Letzter Lauf');
|
||||||
var nextRunNode=valueNodeForLabel('Nächster Lauf');
|
var nextRunNode=valueNodeForLabel('Nächster Lauf');
|
||||||
var lastResultNode=valueNodeForLabel('Letztes Ergebnis');
|
var lastResultNode=lastResultValueNode();
|
||||||
|
|
||||||
function poll(){
|
function poll(){
|
||||||
fetch(endpoint+'?_='+Date.now(),{credentials:'same-origin',cache:'no-store'})
|
fetch(endpoint+'?_='+Date.now(),{credentials:'same-origin',cache:'no-store'})
|
||||||
|
|||||||
Reference in New Issue
Block a user