diff --git a/emhttp/plugins/dynamix/Favorites.page b/emhttp/plugins/dynamix/Favorites.page index f675ecb40..9e4c647de 100644 --- a/emhttp/plugins/dynamix/Favorites.page +++ b/emhttp/plugins/dynamix/Favorites.page @@ -14,6 +14,6 @@ $(function(){ $(this).find('span').append(''); $(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();}); }); diff --git a/emhttp/plugins/dynamix/include/MyFavorites.php b/emhttp/plugins/dynamix/include/MyFavorites.php index c326d4bd8..bd9ec6662 100644 --- a/emhttp/plugins/dynamix/include/MyFavorites.php +++ b/emhttp/plugins/dynamix/include/MyFavorites.php @@ -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');