403Webshell
Server IP : 23.111.136.34  /  Your IP : 216.73.216.136
Web Server : Apache
System : Linux servidor.eurohost.com.br 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User : meusitei ( 1072)
PHP Version : 5.6.40
Disable Function : show_source, system, shell_exec, passthru, proc_open
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/meusitei/public_html/painel/subdominios/234/fotos/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/meusitei/public_html/painel/subdominios/234/fotos/verifica3.php
<?php
session_start();

// Exibir erros (útil para depuração)
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

// Caminho onde o script está rodando (ex.: /var/www/html/clientes/)
$diretorioPrincipal = __DIR__;

if (isset($_POST['deletar_tudo_lote'])) {
    $deletados = excluirArquivosGlobaisLote($diretorioPrincipal, 500);
    $totalRestantes = contarArquivosGlobais($diretorioPrincipal);

    if ($deletados > 0 && $totalRestantes > 0) {
        $msg = "Foram excluídas <strong>$deletados</strong> imagens 1200_ neste lote. Ainda restam <strong>$totalRestantes</strong> imagens para excluir.";
    } elseif ($deletados > 0 && $totalRestantes === 0) {
        $msg = "Foram excluídas <strong>$deletados</strong> imagens 1200_ neste lote. Todas as imagens foram removidas!";
    } else {
        $msg = "Nenhuma imagem 1200_ foi encontrada para exclusão.";
    }
}

if (isset($_POST['deletar_pasta']) && !empty($_POST['pasta'])) {
    $pasta = basename($_POST['pasta']); // proteção contra path traversal
    $pathPasta = $diretorioPrincipal . '/' . $pasta;
    excluirArquivosPasta($pathPasta);
    $msg = "Imagens 1200_ da pasta <strong>$pasta</strong> foram excluídas!";
}

function excluirArquivosPasta($pathPasta) {
    $arquivos = glob($pathPasta . '/1200_*');
    foreach ($arquivos as $arquivo) {
        if (is_file($arquivo)) {
            if (unlink($arquivo)) {
                $logMsg = "[" . date('Y-m-d H:i:s') . "] Arquivo excluído: $arquivo\n";
                file_put_contents(__DIR__ . '/log_exclusoes.txt', $logMsg, FILE_APPEND);
            }
        }
    }
}

function excluirArquivosGlobaisLote($diretorioPrincipal, $maxExcluir = 500) {
    $pastas = array_filter(glob($diretorioPrincipal . '/*'), 'is_dir');
    $totalExcluidos = 0;

    foreach ($pastas as $pastaPath) {
        $arquivos = glob($pastaPath . '/1200_*');
        foreach ($arquivos as $arquivo) {
            if (is_file($arquivo)) {
                if (unlink($arquivo)) {
                    $logMsg = "[" . date('Y-m-d H:i:s') . "] Arquivo excluído: $arquivo\n";
                    file_put_contents(__DIR__ . '/log_exclusoes.txt', $logMsg, FILE_APPEND);
                }
                $totalExcluidos++;
                if ($totalExcluidos >= $maxExcluir) {
                    return $totalExcluidos;
                }
            }
        }
    }
    return $totalExcluidos;
}

function contarArquivosGlobais($diretorioPrincipal) {
    $pastas = array_filter(glob($diretorioPrincipal . '/*'), 'is_dir');
    $total = 0;
    foreach ($pastas as $pastaPath) {
        $arquivos = glob($pastaPath . '/1200_*');
        $total += count($arquivos);
    }
    return $total;
}

// Montar relatório
$relatorio = [];
$totalImagens = 0;
$totalTamanho = 0;

$pastas = array_filter(glob($diretorioPrincipal . '/*'), 'is_dir');

foreach ($pastas as $pastaPath) {
    $pastaNome = basename($pastaPath);
    $arquivos = glob($pastaPath . '/1200_*');

    $quantidade = count($arquivos);
    $tamanho = 0;

    foreach ($arquivos as $arquivo) {
        $tamanho += filesize($arquivo);
    }

    $totalImagens += $quantidade;
    $totalTamanho += $tamanho;

    $tamanhoMB = $tamanho > 0 ? number_format($tamanho / (1024 * 1024), 2) : "0.00";

    $relatorio[] = [
        'pasta' => $pastaNome,
        'quantidade' => $quantidade,
        'tamanhoMB' => $tamanhoMB
    ];
}

// Gera CSV
$csv = "Pasta;Qtd Imagens (1200_);Tamanho (MB)\n";
foreach ($relatorio as $linha) {
    $csv .= "{$linha['pasta']};{$linha['quantidade']};{$linha['tamanhoMB']}\n";
}

file_put_contents(__DIR__ . '/relatorio.csv', $csv);

// Verificar quantas imagens 1200_ ainda existem no total
$totalRestantes = contarArquivosGlobais($diretorioPrincipal);
?>

<!DOCTYPE html>
<html lang="pt-br">
<head>
    <meta charset="UTF-8">
    <title>Verificação de Imagens 1200_</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light">
<div class="container mt-5">

    <h1 class="mb-4">Verificação de Imagens <code>1200_</code></h1>

    <!-- Mensagem informativa de segurança -->
    <div class="alert alert-info">
        <strong>Segurança:</strong> Este sistema só exclui arquivos cujo nome comece com <code>1200_</code>.
        Nenhuma pasta ou arquivo fora desse padrão será apagado. Todas as exclusões são registradas no arquivo <code>log_exclusoes.txt</code>.
    </div>

    <?php if (!empty($msg)): ?>
        <div class="alert alert-info">
            <?= $msg ?>
        </div>
    <?php endif; ?>

    <?php if ($totalRestantes > 0): ?>
        <div class="alert alert-warning">
            Restam ainda <strong><?= $totalRestantes ?></strong> imagens 1200_ para excluir.
        </div>
    <?php else: ?>
        <div class="alert alert-success">
            Parabéns! Todas as imagens 1200_ foram excluídas. Não há mais arquivos pendentes.
        </div>
    <?php endif; ?>

    <form method="post" onsubmit="return confirm('Tem certeza que deseja excluir mais 500 imagens 1200_ de todas as pastas?');">
        <button type="submit" name="deletar_tudo_lote" class="btn btn-danger mb-3">
            Excluir mais 500 imagens 1200_ de TODAS as pastas
        </button>
        <a href="relatorio.csv" class="btn btn-success mb-3" target="_blank">Download Relatório CSV</a>
    </form>

    <table class="table table-striped table-bordered">
        <thead class="table-dark">
            <tr>
                <th>Pasta</th>
                <th>Qtd Imagens (1200_)</th>
                <th>Tamanho (MB)</th>
                <th>Ações</th>
            </tr>
        </thead>
        <tbody>
        <?php foreach ($relatorio as $linha): ?>
            <tr>
                <td><?= htmlspecialchars($linha['pasta']) ?></td>
                <td><?= $linha['quantidade'] ?></td>
                <td><?= $linha['tamanhoMB'] ?></td>
                <td>
                    <form method="post" style="display:inline;" onsubmit="return confirm('Excluir imagens da pasta <?= htmlspecialchars($linha['pasta']) ?>?');">
                        <input type="hidden" name="pasta" value="<?= htmlspecialchars($linha['pasta']) ?>">
                        <button type="submit" name="deletar_pasta" class="btn btn-sm btn-danger">
                            Excluir Imagens
                        </button>
                    </form>
                </td>
            </tr>
        <?php endforeach; ?>
        </tbody>
        <tfoot class="table-secondary">
            <tr>
                <th>Total</th>
                <th><?= $totalImagens ?></th>
                <th><?= number_format($totalTamanho / (1024 * 1024), 2) ?></th>
                <th></th>
            </tr>
        </tfoot>
    </table>
</div>
</body>
</html>

Youez - 2016 - github.com/yon3zu
LinuXploit