Пошел по аналогии дальше
Код: Выделить всё
<?php
/*~ zimages_last_x_att.php
.---------------------------------------------------------------------------.
| Software: zimages_last_x_att - purge phpBB images/last_x_att directory |
| Site: http://c61.no-ip.org/forum/index.php |
| ------------------------------------------------------------------------- |
| Author: Serg c61@yandex.ru |
| Copyright (c) 2012, Serg c61@yandex.ru. All Rights Reserved. |
| ------------------------------------------------------------------------- |
| License: Distributed under the Lesser General Public License (LGPL) |
| http://www.gnu.org/copyleft/lesser.html |
| This program is distributed in the hope that it will be useful - WITHOUT |
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| FITNESS FOR A PARTICULAR PURPOSE. |
'---------------------------------------------------------------------------'*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
if ( !$auth->acl_get('a_') )
{
trigger_error('NO_AUTH_ADMIN');
}
// Version:
$zimages_last_x_att_version = '1.1.0';
//------------------------------------------------------------------------------
//
// c61@yandex.ru : Просмотр и очистка папки images/last_x_att в phpBB
// v1.1.0 : 20140324 : адаптировано к phpBB3.1
// v1.0.3 : 20131015 : несущественные улучшения
// v1.0.2 : 20131010 : добавлена перезагрузка страницы после удаления файла/всех файлов
// исправление несущественных мелочей
// v1.0.1 : 20130404 : в исключения добавлен потерявшийся в результате применения
// любимого китайского метода copy-paste важный файлик queue.php
// v1.0.0 : 20130322 : первый релиз
//
// Параметры:
// Имя Значение Описание
// del файл/1 удалить файл/удалить все файлы
// noshow 1 не показывать таблицу файлов
//
// Примечания:
// 1. .htaccess, index.htm, queue.php, queue.php.lock не удаляются и в списке отсутствуют.
//
//------------------------------------------------------------------------------
// Параметры
$zimages_last_x_att = '.'.DIRECTORY_SEPARATOR.'images/last_x_att';
$noshow = request_var('noshow',0);
$del = request_var('del','');
function dirs_zimages_last_x_att_glob($path, $pattern = '*', $flags = GLOB_NOSORT)
{
$matches = array();
$folders = array(rtrim($path, DIRECTORY_SEPARATOR));
while ($folder = array_shift($folders))
{
$matches = array_merge($matches, glob($folder.DIRECTORY_SEPARATOR.$pattern, $flags));
$moreFolders = glob($folder.DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR);
$folders = array_merge($folders, $moreFolders);
}
return $matches;
}
function zimages_last_x_att_glob($path, $dirs = true)
{
if ( !$dirs ) return glob($path . DIRECTORY_SEPARATOR . '*.*');
else return dirs_zimages_last_x_att_glob($path, '*');
}
if(!empty($del))
{
switch ($del)
{
case 1:
case 2:
case 3:
{
if($g = zimages_last_x_att_glob($zimages_last_x_att, (($del == 1) ? false : true)))
{
arsort($g);
foreach($g as $filename)
{
if(preg_match("|$zimages_last_x_att\/\.htaccess|i",$filename)) continue;
if(preg_match("|$zimages_last_x_att\/index.htm|i",$filename)) continue;
if(preg_match("|$zimages_last_x_att\/queue.php|i",$filename)) continue;
if(preg_match("|$zimages_last_x_att\/queue.php.lock|i",$filename)) continue;
if($del == 1)
{
if(preg_match("|$zimages_last_x_att\/twig|i",$filename)) continue;
}
if($del == 2)
{
if(!preg_match("|$zimages_last_x_att\/twig|i",$filename)) continue;
}
if(is_dir($filename))
{
if($del > 2) @rmdir($filename);
}
else
{
@unlink($filename);
}
}
}
break;
}
default:
{
if(!preg_match("|\.\.\/|",$del))
{
@unlink($zimages_last_x_att . DIRECTORY_SEPARATOR . $del);
}
break;
}
}
if (PHPBB_VERSION >= '3.1.0')
{
$self = $request->server('PHP_SELF');
}
else
{
$self = $_SERVER['PHP_SELF'];
}
exit("<meta http-equiv='refresh' content='0; url=$self'>");
}
if(!$noshow)
{
if($g = zimages_last_x_att_glob($zimages_last_x_att))
{
asort($g);
@header( 'Content-type: text/html; charset=utf-8' );
echo '<script type="text/javascript">';
echo 'function yesno(){return confirm("Удалить ?");}';
echo '</script>';
echo '<font face="monospace"><table width="100%" border="1" cellspacing="0" cellpadding="2">';
echo '<tr>';
echo '<th colspan="4" align="center">Просмотр и очистка папки images/last_x_att на хосте для phpBB (' . $zcache . ')</th>';
echo '</tr>';
echo '<tr>';
echo '<th colspan="4" align="center">';
echo '[<a href="zimages_last_x_att.php">Обновить</a>]';
echo ' ';
echo '[<a href="zimages_last_x_att.php?del=1" onclick="javascript:return yesno();">Удалить ' . $zcache . DIRECTORY_SEPARATOR . '*.*</a>]';
if (in_array($zcache . DIRECTORY_SEPARATOR . 'twig',$g))
{
echo ' ';
echo '[<a href="zimages_last_x_att.php?del=2" onclick="javascript:return yesno();">Удалить ' . $zcache . DIRECTORY_SEPARATOR . '*' . DIRECTORY_SEPARATOR . '*.*</a>]';
echo ' ';
echo '[<a href="zimages_last_x_att.php?del=3" onclick="javascript:return yesno();">Удалить ВСЁ</a>]';
}
echo '</th>';
echo '</tr>';
echo '<tr>';
echo '<th width="1%" align="center">N</th>';
echo '<th width="59%" align="left">Файл</th>';
echo '<th width="20%" align="right">Дата/Время</th>';
echo '<th width="20%" align="right">Размер, байт</th>';
echo '</tr>';
$n = 0;
$totalsize = 0;
foreach($g as $filename)
{
if(preg_match("|$zimages_last_x_att\/\.htaccess|i",$filename)) continue;
if(preg_match("|$zimages_last_x_att\/index.htm|i",$filename)) continue;
if(preg_match("|$zimages_last_x_att\/queue.php|i",$filename)) continue;
if(preg_match("|$zimages_last_x_att\/queue.php.lock|i",$filename)) continue;
$n++;
$size = filesize($filename);
$totalsize += $size;
$strsize = str_replace(' ',' ',number_format($size,0,'.',' '));
$file = str_replace($zcache . DIRECTORY_SEPARATOR,'',$filename);
echo '<tr>';
echo '<td width="1%" align="center">' . $n . '</td>';
echo '<td width="59%">';
if (!is_dir($filename)) echo '<a href="zimages_last_x_att.php?del=' . $file . '" onclick="javascript:return yesno();">' . $file . '</a>';
else echo $file;
echo '</td>';
echo '<td width="20%" align="right">' . date("Y.m.d/H:i:s",fileatime($filename)) . '</td>';
echo '<td width="20%" align="right">';
if (!is_dir($filename)) echo $strsize;
else echo 'Dir';
echo '</td>';
echo '</tr>';
}
$strsize = str_replace(' ',' ',number_format($totalsize,0,'.',' '));
echo '<tr>';
echo '<th width="80%" colspan="3" align="right">Всего</th>';
echo '<th width="20%" align="right">' . $strsize . '</th>';
echo '</tr>';
echo '</table></font>';
echo '<div width="100%" align="right"><small><i><a href="http://c61.no-ip.org" target="_blank">ZImages_last_x_att</a> v.' . $zimages_last_x_att_version . ' (C) 2013 <a href="mailto:c61@yandex.ru">c61</a></i></small></div>';
}
}
?>
Что-нибудь накосячил?
Хм....
1388.jpg
Класс.... Осталось придумать как создавать кнопки, да что б попроще (можно и текстовые) и чтоб прям в стиле торчали... Что-то мысли кончились...
А кнопок таких проклонированных надо аж 6 штук...
Получается обычные текстовые ссылки - самое то, так как админские права уже вложены в скрипт... А блок кнопок можно спрятать и под индивидуальные права одного... (не фиг всем админам тыкать)
Добавлено спустя 22 минуты 45 секунд:
Пчелкин писал(а):Что-нибудь накосячил?
Ага... накосячил
Код: Выделить всё
<?php
/*~ zimages_last_x_att.php
.---------------------------------------------------------------------------.
| Software: zimages_last_x_att - purge phpBB images/last_x_att directory |
| Site: http://c61.no-ip.org/forum/index.php |
| ------------------------------------------------------------------------- |
| Author: Serg c61@yandex.ru |
| Copyright (c) 2012, Serg c61@yandex.ru. All Rights Reserved. |
| ------------------------------------------------------------------------- |
| License: Distributed under the Lesser General Public License (LGPL) |
| http://www.gnu.org/copyleft/lesser.html |
| This program is distributed in the hope that it will be useful - WITHOUT |
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| FITNESS FOR A PARTICULAR PURPOSE. |
'---------------------------------------------------------------------------'*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
if ( !$auth->acl_get('a_') )
{
trigger_error('NO_AUTH_ADMIN');
}
// Version:
$zimages_last_x_att_version = '1.1.0';
//------------------------------------------------------------------------------
//
// c61@yandex.ru : Просмотр и очистка папки images/last_x_att в phpBB
// v1.1.0 : 20140324 : адаптировано к phpBB3.1
// v1.0.3 : 20131015 : несущественные улучшения
// v1.0.2 : 20131010 : добавлена перезагрузка страницы после удаления файла/всех файлов
// исправление несущественных мелочей
// v1.0.1 : 20130404 : в исключения добавлен потерявшийся в результате применения
// любимого китайского метода copy-paste важный файлик queue.php
// v1.0.0 : 20130322 : первый релиз
//
// Параметры:
// Имя Значение Описание
// del файл/1 удалить файл/удалить все файлы
// noshow 1 не показывать таблицу файлов
//
// Примечания:
// 1. .htaccess, index.htm, queue.php, queue.php.lock не удаляются и в списке отсутствуют.
//
//------------------------------------------------------------------------------
// Параметры
$zimages_last_x_att = '.'.DIRECTORY_SEPARATOR.'images/last_x_att';
$noshow = request_var('noshow',0);
$del = request_var('del','');
function dirs_zimages_last_x_att_glob($path, $pattern = '*', $flags = GLOB_NOSORT)
{
$matches = array();
$folders = array(rtrim($path, DIRECTORY_SEPARATOR));
while ($folder = array_shift($folders))
{
$matches = array_merge($matches, glob($folder.DIRECTORY_SEPARATOR.$pattern, $flags));
$moreFolders = glob($folder.DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR);
$folders = array_merge($folders, $moreFolders);
}
return $matches;
}
function zimages_last_x_att_glob($path, $dirs = true)
{
if ( !$dirs ) return glob($path . DIRECTORY_SEPARATOR . '*.*');
else return dirs_zimages_last_x_att_glob($path, '*');
}
if(!empty($del))
{
switch ($del)
{
case 1:
case 2:
case 3:
{
if($g = zimages_last_x_att_glob($zimages_last_x_att, (($del == 1) ? false : true)))
{
arsort($g);
foreach($g as $filename)
{
if(preg_match("|$zimages_last_x_att\/\.htaccess|i",$filename)) continue;
if(preg_match("|$zimages_last_x_att\/index.htm|i",$filename)) continue;
if(preg_match("|$zimages_last_x_att\/queue.php|i",$filename)) continue;
if(preg_match("|$zimages_last_x_att\/queue.php.lock|i",$filename)) continue;
if($del == 1)
{
if(preg_match("|$zimages_last_x_att\/twig|i",$filename)) continue;
}
if($del == 2)
{
if(!preg_match("|$zimages_last_x_att\/twig|i",$filename)) continue;
}
if(is_dir($filename))
{
if($del > 2) @rmdir($filename);
}
else
{
@unlink($filename);
}
}
}
break;
}
default:
{
if(!preg_match("|\.\.\/|",$del))
{
@unlink($zimages_last_x_att . DIRECTORY_SEPARATOR . $del);
}
break;
}
}
if (PHPBB_VERSION >= '3.1.0')
{
$self = $request->server('PHP_SELF');
}
else
{
$self = $_SERVER['PHP_SELF'];
}
exit("<meta http-equiv='refresh' content='0; url=$self'>");
}
if(!$noshow)
{
if($g = zimages_last_x_att_glob($zimages_last_x_att))
{
asort($g);
@header( 'Content-type: text/html; charset=utf-8' );
echo '<script type="text/javascript">';
echo 'function yesno(){return confirm("Удалить ?");}';
echo '</script>';
echo '<font face="monospace"><table width="100%" border="1" cellspacing="0" cellpadding="2">';
echo '<tr>';
echo '<th colspan="4" align="center">Просмотр и очистка папки images/last_x_att на хосте для phpBB (' . $zimages_last_x_att . ')</th>';
echo '</tr>';
echo '<tr>';
echo '<th colspan="4" align="center">';
echo '[<a href="zimages_last_x_att.php">Обновить</a>]';
echo ' ';
echo '[<a href="zimages_last_x_att.php?del=1" onclick="javascript:return yesno();">Удалить ' . $zimages_last_x_att . DIRECTORY_SEPARATOR . '*.*</a>]';
if (in_array($zimages_last_x_att . DIRECTORY_SEPARATOR . 'twig',$g))
{
echo ' ';
echo '[<a href="zimages_last_x_att.php?del=2" onclick="javascript:return yesno();">Удалить ' . $zimages_last_x_att . DIRECTORY_SEPARATOR . '*' . DIRECTORY_SEPARATOR . '*.*</a>]';
echo ' ';
echo '[<a href="zimages_last_x_att.php?del=3" onclick="javascript:return yesno();">Удалить ВСЁ</a>]';
}
echo '</th>';
echo '</tr>';
echo '<tr>';
echo '<th width="1%" align="center">N</th>';
echo '<th width="59%" align="left">Файл</th>';
echo '<th width="20%" align="right">Дата/Время</th>';
echo '<th width="20%" align="right">Размер, байт</th>';
echo '</tr>';
$n = 0;
$totalsize = 0;
foreach($g as $filename)
{
if(preg_match("|$zimages_last_x_att\/\.htaccess|i",$filename)) continue;
if(preg_match("|$zimages_last_x_att\/index.htm|i",$filename)) continue;
if(preg_match("|$zimages_last_x_att\/queue.php|i",$filename)) continue;
if(preg_match("|$zimages_last_x_att\/queue.php.lock|i",$filename)) continue;
$n++;
$size = filesize($filename);
$totalsize += $size;
$strsize = str_replace(' ',' ',number_format($size,0,'.',' '));
$file = str_replace($zimages_last_x_att . DIRECTORY_SEPARATOR,'',$filename);
echo '<tr>';
echo '<td width="1%" align="center">' . $n . '</td>';
echo '<td width="59%">';
if (!is_dir($filename)) echo '<a href="zimages_last_x_att.php?del=' . $file . '" onclick="javascript:return yesno();">' . $file . '</a>';
else echo $file;
echo '</td>';
echo '<td width="20%" align="right">' . date("Y.m.d/H:i:s",fileatime($filename)) . '</td>';
echo '<td width="20%" align="right">';
if (!is_dir($filename)) echo $strsize;
else echo 'Dir';
echo '</td>';
echo '</tr>';
}
$strsize = str_replace(' ',' ',number_format($totalsize,0,'.',' '));
echo '<tr>';
echo '<th width="80%" colspan="3" align="right">Всего</th>';
echo '<th width="20%" align="right">' . $strsize . '</th>';
echo '</tr>';
echo '</table></font>';
echo '<div width="100%" align="right"><small><i><a href="http://c61.no-ip.org" target="_blank">ZImages_last_x_att</a> v.' . $zimages_last_x_att_version . ' (C) 2013 <a href="mailto:c61@yandex.ru">c61</a></i></small></div>';
}
}
?>
остались две ошибки
Язык: ru Страница: zimages_last_x_att.php
Файл: [ROOT]/zimages_last_x_att.php
Строка: 68 [PHP Warning]
array_merge(): Argument #2 is not an array
Код: Выделить всё
$folders = array_merge($folders, $moreFolders);
Язык: ru Страница: zimages_last_x_att.php
Файл: [ROOT]/zimages_last_x_att.php
Строка: 64 [PHP Warning]
array_shift() expects parameter 1 to be array, null given
Чаво ему не нравится еще?
Но скрипт работает и удаляет намана... тока вот дебагг орет...
Добавлено спустя 4 минуты 31 секунду:
А показывает уже с путем -
1389.jpg
У вас нет необходимых прав для просмотра вложений в этом сообщении.