Skip to content

Commit

Permalink
Update prune_attachments.php
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSheer committed Mar 13, 2019
1 parent 6c9307e commit 62a21ac
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions tools/admin/prune_attachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ function display_options()

$dir = '' . PHPBB_ROOT_PATH . '' . $config['upload_path'];
$files_list = $cache->get('_stk_prune_attachments'); // Try get data from cache
if(!$files_list)
if (!$files_list)
{
// No data in cache
$files = scan($dir, $files);
$sql = 'SELECT attach_id, physical_filename
FROM ' . ATTACHMENTS_TABLE;
$result = $db->sql_query($sql);

while($data = $db->sql_fetchrow($result))
while ($data = $db->sql_fetchrow($result))
{
if($subfolders)
if ($subfolders)
{
// Attachments in subfolders
$ais_folder_1 = substr(substr($data['attach_id'] + 1000000, -6), 0, 2);
Expand Down Expand Up @@ -101,15 +101,15 @@ function display_options()
sort($files);
$count++;
}
if($count > ($this->_batch_size - 1))
if ($count > ($this->_batch_size - 1))
{
$cache->destroy('_stk_prune_attachments');
$cache->put('_stk_prune_attachments', $files);
break;
}
}

if(sizeof($delete_list))
if (sizeof($delete_list))
{
$list .= implode('<br />', $delete_list);
$exit = false;
Expand All @@ -120,12 +120,12 @@ function display_options()
$exit = true;
}

if(sizeof($unsuccess))
if (sizeof($unsuccess))
{
$list .= '' . user_lang('PRUNE_ATTACHMENTS_FAIL') . '<br />' . implode('<br />', $unsuccess) . '';
}

if($exit)
if ($exit)
{
$cache->destroy('_stk_prune_attachments');
if ((sizeof($unsuccess)))
Expand All @@ -148,10 +148,6 @@ function display_options()

$template->assign_vars(array(
'U_DISPLAY_ACTION' => append_sid(STK_INDEX, 't=prune_attachments&amp;go=1'),
/*
'L_PRUNE_ATTACHMENTS' => user_lang('PRUNE_ATTACHMENTS'),
'L_PRUNE_ATTACHMENTS_EXPLAIN' => user_lang('PRUNE_ATTACHMENTS_EXPLAIN'),
*/
));

$template->set_filenames(array(
Expand All @@ -164,16 +160,24 @@ function display_options()

function scan($path,&$res)
{
global $config;

$mass = scandir($path);
for($i = 0; $i <= count($mass) - 1; $i++)

if ($path == '' . PHPBB_ROOT_PATH . '' . $config['upload_path'] .'/phpbbgallery')
{
return;
}

for ($i = 0; $i <= count($mass) - 1; $i++)
{
if($mass[$i] != '..' && $mass[$i] != '.' && $mass[$i] != 'index.htm' && $mass[$i] != '.htaccess')
if ($mass[$i] != '..' && $mass[$i] != '.' && $mass[$i] != 'index.htm' && $mass[$i] != '.htaccess')
{
array_push($res, '' . $path . '/' . $mass[$i] . '');
}
if(!strstr($mass[$i], '.'))
if (!strstr($mass[$i], '.'))
{
if(is_dir($path . '/' . $mass[$i]))
if (is_dir($path . '/' . $mass[$i]))
{
scan($path . '/' . $mass[$i], $res);
}
Expand Down

0 comments on commit 62a21ac

Please sign in to comment.