Atualização automática: 2026-05-18 11:00:54
This commit is contained in:
@@ -72,10 +72,10 @@ class WgetCloner {
|
|||||||
console.log(`🌐 URL: ${url}\n`);
|
console.log(`🌐 URL: ${url}\n`);
|
||||||
|
|
||||||
// Sempre usar o wget.exe local primeiro
|
// Sempre usar o wget.exe local primeiro
|
||||||
let wgetCommand = this.wgetPath;
|
let wgetCommand = '/bin/wget'; // Linux system wget
|
||||||
|
|
||||||
// Verificar se o wget.exe local existe
|
// Verificar se o wget.exe local existe
|
||||||
if (!fs.existsSync(this.wgetPath)) {
|
if (false) { // bypass wget.exe check
|
||||||
console.log('⚠️ wget.exe local não encontrado');
|
console.log('⚠️ wget.exe local não encontrado');
|
||||||
|
|
||||||
// Tentar baixar
|
// Tentar baixar
|
||||||
@@ -168,13 +168,19 @@ class WgetCloner {
|
|||||||
console.log(`${'='.repeat(60)}\n`);
|
console.log(`${'='.repeat(60)}\n`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// countFiles inline helper
|
||||||
|
var countFiles = function(dir) { var ts=0,fc=0; (function rec(d){if(!fs.existsSync(d))return;fs.readdirSync(d).forEach(function(i){var p=path.join(d,i),s=fs.statSync(p);if(s.isDirectory()&&i.indexOf("cloned-sites")==-1&&i.indexOf(".versions")==-1)rec(p);else if(!s.isDirectory()){ts+=s.size;fc++;}});})(dir);return{fileCount:fc,totalSize:ts};};
|
||||||
|
|
||||||
// Criar arquivo de informações
|
// Criar arquivo de informações
|
||||||
|
const stats = countFiles(siteDir);
|
||||||
const info = {
|
const info = {
|
||||||
originalUrl: url,
|
originalUrl: url,
|
||||||
clonedAt: new Date().toISOString(),
|
clonedAt: new Date().toISOString(),
|
||||||
directory: siteDir,
|
directory: siteDir,
|
||||||
method: 'wget',
|
method: 'wget',
|
||||||
success: true
|
success: true,
|
||||||
|
fileCount: stats.fileCount,
|
||||||
|
totalSize: stats.totalSize
|
||||||
};
|
};
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ function populateOverview(data) {
|
|||||||
if (data.cloneInfo) {
|
if (data.cloneInfo) {
|
||||||
overviewItems.push(
|
overviewItems.push(
|
||||||
{ label: 'Clone Status', value: data.cloneInfo.success ? '✅ Sucesso' : '❌ Falhou' },
|
{ label: 'Clone Status', value: data.cloneInfo.success ? '✅ Sucesso' : '❌ Falhou' },
|
||||||
{ label: 'Assets Baixados', value: `${data.cloneInfo.assetsDownloaded}/${data.cloneInfo.totalAssets}` },
|
{ label: 'Assets Baixados', value: data.cloneInfo.fileCount ? `${data.cloneInfo.fileCount} arquivos (${formatBytes(data.cloneInfo.totalSize || 0)})` : 'verificando...' },
|
||||||
{ label: 'Diretório Local', value: data.cloneInfo.directory }
|
{ label: 'Diretório Local', value: data.cloneInfo.directory }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -435,18 +435,8 @@ function openCloneFolder(directory) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function openClonedSite(directory) {
|
function openClonedSite(directory) {
|
||||||
// Tentar abrir o index.html do site clonado
|
// Extract folder name and open site in browser via window.open
|
||||||
fetch('/api/open-site', {
|
const folderName = directory.split('/').pop();
|
||||||
method: 'POST',
|
const siteUrl = window.location.protocol + '//' + window.location.host + '/' + folderName + '/index.html';
|
||||||
headers: {
|
window.open(siteUrl, '_blank');
|
||||||
'Content-Type': 'application/json'
|
|
||||||
},
|
|
||||||
body: JSON.stringify({ path: directory })
|
|
||||||
}).then(response => {
|
|
||||||
if (!response.ok) {
|
|
||||||
alert('Não foi possível abrir o site automaticamente.\nAbra manualmente: ' + directory + '\\index.html');
|
|
||||||
}
|
|
||||||
}).catch(error => {
|
|
||||||
alert('Não foi possível abrir o site automaticamente.\nAbra manualmente: ' + directory + '\\index.html');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
+23
-6
@@ -5,7 +5,11 @@ const axios = require('axios');
|
|||||||
const { exec, spawn } = require('child_process');
|
const { exec, spawn } = require('child_process');
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const PORT = 4000;
|
const PORT = process.env.PORT || 3000;
|
||||||
|
|
||||||
|
// Storage manager routes
|
||||||
|
const storageManager = require('./storage-manager');
|
||||||
|
app.use('/api/clones', storageManager);
|
||||||
|
|
||||||
// Security headers
|
// Security headers
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
@@ -71,6 +75,19 @@ app.post('/api/wget-clone', async (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
console.log('✅ Wget clone completed successfully');
|
console.log('✅ Wget clone completed successfully');
|
||||||
|
|
||||||
|
// Sync to host /root/Desktop/Clonados
|
||||||
|
if (response.data && response.data.success && response.data.directory) {
|
||||||
|
const { exec } = require('child_process');
|
||||||
|
const containerId = require('os').hostname();
|
||||||
|
const cloneDir = response.data.directory.split('/').pop();
|
||||||
|
const hostDir = '/root/Desktop/Clonados';
|
||||||
|
exec(`docker cp b38l2zsxjv08xkxg4gd5rl9r-210808689309:${response.data.directory} ${hostDir}/ 2>/dev/null`, (err) => {
|
||||||
|
if (err) console.log('⚠️ Sync to host failed:', err.message);
|
||||||
|
else console.log('✅ Clone synced to host:', cloneDir);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
res.json(response.data);
|
res.json(response.data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('❌ Wget clone error:', error.message);
|
console.error('❌ Wget clone error:', error.message);
|
||||||
@@ -176,8 +193,8 @@ app.post('/api/open-folder', (req, res) => {
|
|||||||
return res.status(400).json({ error: 'Caminho da pasta é obrigatório' });
|
return res.status(400).json({ error: 'Caminho da pasta é obrigatório' });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Abrir pasta no Windows Explorer
|
// Abrir pasta no gerenciador de ficheiros
|
||||||
exec(`explorer "${folderPath}"`, (error) => {
|
exec(`xdg-open "${folderPath}"`, (error) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('Erro ao abrir pasta:', error);
|
console.error('Erro ao abrir pasta:', error);
|
||||||
return res.status(500).json({ error: 'Não foi possível abrir a pasta' });
|
return res.status(500).json({ error: 'Não foi possível abrir a pasta' });
|
||||||
@@ -204,8 +221,8 @@ app.post('/api/open-site', (req, res) => {
|
|||||||
|
|
||||||
console.log(`🌍 Opening site via HTTP: ${siteUrl}`);
|
console.log(`🌍 Opening site via HTTP: ${siteUrl}`);
|
||||||
|
|
||||||
// Abrir URL no navegador padrão
|
// Abrir URL no navegador padrão (Linux)
|
||||||
exec(`start "" "${siteUrl}"`, (error) => {
|
exec(`xdg-open "${siteUrl}"`, (error) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('Erro ao abrir site:', error);
|
console.error('Erro ao abrir site:', error);
|
||||||
return res.status(500).json({ error: 'Não foi possível abrir o site via HTTP' });
|
return res.status(500).json({ error: 'Não foi possível abrir o site via HTTP' });
|
||||||
@@ -246,7 +263,7 @@ app.post('/api/open-navigation', (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.get('/', (req, res) => {
|
app.get('/', (req, res) => {
|
||||||
res.sendFile(path.join(__dirname, 'public', 'index-premium.html'));
|
res.sendFile(path.join(__dirname, 'public', 'index-new.html'));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Serve old interface
|
// Serve old interface
|
||||||
|
|||||||
Reference in New Issue
Block a user