mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 20:57:26 +02:00
Fixes duplicate paths in zipped language-pack. Excludes non-core plugins and themes.
This commit is contained in:
@@ -677,14 +677,18 @@ class lancheck
|
|||||||
|
|
||||||
$archive = new PclZip($newfile);
|
$archive = new PclZip($newfile);
|
||||||
|
|
||||||
$core = $this->getFilePaths(e_LANGUAGEDIR.$language."/", $language,'', 0);
|
$core = $this->getFilePaths(e_LANGUAGEDIR.$language."/", $language,''); // includes admin area.
|
||||||
$core_admin = $this->getFilePaths(e_BASE.$LANGUAGES_DIRECTORY.$language."/admin/", $language,'', 2);
|
// $core_admin = $this->getFilePaths(e_BASE.$LANGUAGES_DIRECTORY.$language."/admin/", $language,'');
|
||||||
|
$core_admin = array();
|
||||||
$plugs = $this->getFilePaths(e_BASE.$PLUGINS_DIRECTORY, $language, $this->core_plugins); // standardized path.
|
$plugs = $this->getFilePaths(e_BASE.$PLUGINS_DIRECTORY, $language, $this->core_plugins); // standardized path.
|
||||||
$theme = $this->getFilePaths(e_BASE.$THEMES_DIRECTORY, $language, $this->core_themes);
|
$theme = $this->getFilePaths(e_BASE.$THEMES_DIRECTORY, $language, $this->core_themes);
|
||||||
$docs = $this->getFilePaths(e_BASE.$HELP_DIRECTORY,$language);
|
$docs = $this->getFilePaths(e_BASE.$HELP_DIRECTORY,$language);
|
||||||
$handlers = $this->getFilePaths(e_BASE.$HANDLERS_DIRECTORY,$language); // standardized path.
|
$handlers = $this->getFilePaths(e_BASE.$HANDLERS_DIRECTORY,$language); // standardized path.
|
||||||
|
|
||||||
$file = array_merge($core,$core_admin, $plugs, $theme, $docs, $handlers);
|
$file = array_merge($core,$core_admin, $plugs, $theme, $docs, $handlers);
|
||||||
|
|
||||||
|
$file = array_unique($file);
|
||||||
|
|
||||||
$data = implode(",", $file);
|
$data = implode(",", $file);
|
||||||
|
|
||||||
if ($archive->create($data,PCLZIP_OPT_REMOVE_PATH,e_BASE) == 0)
|
if ($archive->create($data,PCLZIP_OPT_REMOVE_PATH,e_BASE) == 0)
|
||||||
@@ -735,19 +739,21 @@ class lancheck
|
|||||||
* @param string $filter
|
* @param string $filter
|
||||||
* @return array|bool
|
* @return array|bool
|
||||||
*/
|
*/
|
||||||
private function getFilePaths($path, $language)
|
private function getFilePaths($path, $language, $restrict=array())
|
||||||
{
|
{
|
||||||
$fl = e107::getFile();
|
$fl = e107::getFile();
|
||||||
|
|
||||||
if ($lanlist = $fl->get_files($path, "", "standard", 4))
|
if ($lanlist = $fl->get_files($path, "", "standard", 4)) // (\.php|\.xml)$
|
||||||
{
|
{
|
||||||
sort($lanlist);
|
sort($lanlist);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return false;
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$pzip = array();
|
$pzip = array();
|
||||||
foreach ($lanlist as $p)
|
foreach ($lanlist as $p)
|
||||||
{
|
{
|
||||||
@@ -758,6 +764,30 @@ class lancheck
|
|||||||
$pzip[] = $fullpath;
|
$pzip[] = $fullpath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(!empty($restrict)) // strip the list according to inclusion list.
|
||||||
|
{
|
||||||
|
$newlist = array();
|
||||||
|
foreach($pzip as $k=>$p)
|
||||||
|
{
|
||||||
|
foreach($restrict as $accept)
|
||||||
|
{
|
||||||
|
if(strpos($p, $accept)!==false)
|
||||||
|
{
|
||||||
|
|
||||||
|
$newlist[] = $p;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$pzip = $newlist;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $pzip;
|
return $pzip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user