Пример #1
0
function delFsTree($dir)
{
    if (empty($dir)) {
        return false;
    }
    if (!is_dir($dir) && is_file($dir)) {
        return unlink($dir);
        ## delete file
    }
    if (!is_dir($dir)) {
        return;
    }
    $files = array_diff(scandir($dir), array('.', '..'));
    foreach ($files as $file) {
        is_dir("{$dir}/{$file}") ? delFsTree("{$dir}/{$file}") : unlink("{$dir}/{$file}");
    }
    return rmdir($dir);
}
Пример #2
0
                     print '<br/>';
                     if (copy_recursive($GLOBALS['tmpdir'] . '/phpListPluginInstall/' . $dir_prefix . '/plugins/' . $dirEntry, $pluginDestination . '/' . $dirEntry)) {
                         delFsTree($pluginDestination . '/' . $dirEntry . '.' . $bu_dir);
                         $installOk = true;
                     } elseif (is_dir($pluginDestination . '/' . $dirEntry . '.' . $bu_dir)) {
                         ## try to place old one back
                         @rename($pluginDestination . '/' . $dirEntry . '.' . $bu_dir, $pluginDestination . '/' . $dirEntry);
                     }
                 }
             }
             foreach ($pluginInfo as $plugin => $pluginDetails) {
                 #  print 'Writing '.$pluginDestination.'/'.$plugin.'.info.txt<br/>';
                 file_put_contents($pluginDestination . '/' . $plugin . '.info.txt', serialize($pluginDetails));
             }
             ## clean up
             delFsTree($GLOBALS['tmpdir'] . '/phpListPluginInstall');
             if ($installOk) {
                 upgradePlugins($pluginsForUpgrade);
                 print s('Plugin installed successfully');
             } else {
                 print s('Error installing plugin');
             }
             $zip->close();
             print '<hr/>' . PageLinkButton('plugins', s('Continue'));
             return;
         }
     } else {
         Error(s('Plugin directory is not writable'));
     }
 } else {
     Error(s('Invalid plugin package'));