mirror of
https://github.com/unraid/webgui.git
synced 2026-01-04 08:29:51 -06:00
Favorites: automatically clean non-existing pages
This commit is contained in:
@@ -14,6 +14,6 @@ $(function(){
|
||||
$(this).find('span').append('<i class="fa fa-heartbeat favo" title="_(Remove from favorites)_" onclick="delPage("'+page+'");return false"></i>');
|
||||
$(this).hover(function(){$(this).find('i.favo').show();},function(){$(this).find('i.favo').hide();});
|
||||
});
|
||||
if ($('div.Panel').length==0) $('#nofavs').show();
|
||||
$.post('/webGui/include/MyFavorites.php',{action:'clear'},function(){if ($('div.Panel').length==0) $('#nofavs').show();});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -14,10 +14,21 @@
|
||||
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
|
||||
$permit = ['del','add'];
|
||||
$action = $_POST['action']??'';
|
||||
$page = glob("$docroot/plugins/*/{$_POST['page']}.page",GLOB_NOSORT)[0];
|
||||
$cfg = '/boot/config/favorites.cfg';
|
||||
|
||||
// remove non-existing pages
|
||||
if ($action=='clear') {
|
||||
if (file_exists($cfg)) foreach (file($cfg,FILE_IGNORE_NEW_LINES) as $page) {
|
||||
if (!file_exists($page)) {
|
||||
$page = str_replace('/','\/',$page);
|
||||
exec("sed -i '/$page/d' $cfg 2>/dev/null");
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
// validate input
|
||||
$page = glob("$docroot/plugins/*/{$_POST['page']}.page",GLOB_NOSORT)[0];
|
||||
if (!$page || !in_array($action,$permit)) exit;
|
||||
|
||||
$file = fopen($page,'r');
|
||||
|
||||
Reference in New Issue
Block a user