Server IP : 89.26.249.46  /  Your IP : 216.73.216.42
Web Server : Apache
System : Linux a.cp.cloudlink.pt 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User : eticalga ( 1129)
PHP Version : 8.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/eticalga/www/files/themes/kobuxeticalgarve/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/eticalga/www/files/themes/kobuxeticalgarve/webpack-setup.js
const fs = require('fs');
const path = require('path');
const packageJSON = require('./package.json');

const walk = (dir) => {
    try {
        let results = [];
        const list = fs.readdirSync(dir);
        list.forEach((file) => {
            file = path.join(dir, file);
            const stat = fs.statSync(file);
            if (stat && stat.isDirectory()) {
                // Recurse into subdir
                results = [...results, ...walk(file)];
            } else {
                // Is a file
                results.push(file);
            }
        });
        return results;
    } catch (error) {
        console.error(`Error when walking dir ${dir}`, error);
    }
};

const edit = (filePath) => {
    const oldContent = fs.readFileSync(filePath, { encoding: 'utf8' });

    const mapObj = {
        kobuwpthemeTitle: packageJSON.title,
        kobuwpthemeDescription: packageJSON.description,
        kobuwpthemeClient: packageJSON.client,
        kobuwpthemeYear: packageJSON.year,
        kobuwptheme: packageJSON.name,
        KOBUWPTHEME: packageJSON.constant
    };

    const regex = new RegExp(Object.keys(mapObj).join('|'), 'gi');

    const newContent = oldContent.replace(regex, function (matched) {
        return mapObj[matched];
    });
    fs.writeFileSync(filePath, newContent, { encoding: 'utf-8' });
    console.log(`Edited file: ${filePath}`);
};

const main = () => {
    let filePaths = [];

    const files = ['404.php', 'archive.php', 'content-list-post.php', 'content-none.php', 'footer.php', 'functions.php', 'header.php', 'home.php', 'index.php', 'page.php', 'searchform.php', 'single.php', 'style.css', 'inc', 'partials', 'templates'];

    files.forEach((file) => {
        const stat = fs.statSync(file);
        if (stat && stat.isDirectory()) {
            // Recurse into subdir
            filePaths = [...filePaths, ...walk(file)];
        } else {
            // Is a file
            filePaths.push(file);
        }
    });

    filePaths.forEach((filePath) => edit(filePath));
};

// Replaces "kobuwptheme" string with package.json info in all theme files
main();