mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-05-18 07:16:11 +02:00
bug:2898 make some updates methods static + factorize code from plugins, themes & languages
git-svn-id: http://piwigo.org/svn/trunk@23821 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -112,10 +112,7 @@ UPDATE '.USER_INFOS_TABLE.'
|
||||
;';
|
||||
pwg_query($query);
|
||||
|
||||
if (!$this->deltree(PHPWG_ROOT_PATH.'language/'.$language_id))
|
||||
{
|
||||
$this->send_to_trash(PHPWG_ROOT_PATH.'language/'.$language_id);
|
||||
}
|
||||
deltree(PHPWG_ROOT_PATH.'language/'.$language_id, PHPWG_ROOT_PATH.'language/trash');
|
||||
break;
|
||||
|
||||
case 'set_default':
|
||||
@@ -381,10 +378,7 @@ UPDATE '.USER_INFOS_TABLE.'
|
||||
}
|
||||
elseif (is_dir($path))
|
||||
{
|
||||
if (!$this->deltree($path))
|
||||
{
|
||||
$this->send_to_trash($path);
|
||||
}
|
||||
deltree($path, PHPWG_ROOT_PATH.'language/trash');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -405,59 +399,6 @@ UPDATE '.USER_INFOS_TABLE.'
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* delete $path directory
|
||||
* @param string - path
|
||||
*/
|
||||
function deltree($path)
|
||||
{
|
||||
if (is_dir($path))
|
||||
{
|
||||
$fh = opendir($path);
|
||||
while ($file = readdir($fh))
|
||||
{
|
||||
if ($file != '.' and $file != '..')
|
||||
{
|
||||
$pathfile = $path . '/' . $file;
|
||||
if (is_dir($pathfile))
|
||||
{
|
||||
$this->deltree($pathfile);
|
||||
}
|
||||
else
|
||||
{
|
||||
@unlink($pathfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($fh);
|
||||
return @rmdir($path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* send $path to trash directory
|
||||
* @param string - path
|
||||
*/
|
||||
function send_to_trash($path)
|
||||
{
|
||||
$trash_path = PHPWG_ROOT_PATH . 'language/trash';
|
||||
if (!is_dir($trash_path))
|
||||
{
|
||||
@mkdir($trash_path);
|
||||
$file = @fopen($trash_path . '/.htaccess', 'w');
|
||||
@fwrite($file, 'deny from all');
|
||||
@fclose($file);
|
||||
}
|
||||
while ($r = $trash_path . '/' . md5(uniqid(rand(), true)))
|
||||
{
|
||||
if (!is_dir($r))
|
||||
{
|
||||
@rename($path, $r);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort functions
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user