!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/var/www/html/laravel-crm/node_modules/laravel-vite-plugin/bin/   drwxrwxrwx
Free 13.17 GB of 57.97 GB (22.71%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     clean.js (2.52 KB)      -rw-rw-rw-
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
#!/usr/bin/env node

import { readFileSync, readdirSync, unlinkSync, existsSync } from 'fs'
import { dirname } from 'path'

/*
 * Argv helpers.
 */

const argument = (name) => {
    const index = process.argv.findIndex(argument => argument.startsWith(`--${name}=`))

    return index === -1
        ? undefined
        : process.argv[index].substring(`--${name}=`.length)
}

const option = (name) => process.argv.includes(`--${name}`)

/*
 * Helpers.
 */
const info = option(`quiet`) ? (() => undefined) : console.log
const error = option(`quiet`) ? (() => undefined) : console.error

/*
 * Clean.
 */

const main = () => {
    const manifestPaths = argument(`manifest`) ? [argument(`manifest`)] : (option(`ssr`)
        ? [`./bootstrap/ssr/ssr-manifest.json`, `./bootstrap/ssr/manifest.json`]
        : [`./public/build/manifest.json`])

    const foundManifestPath = manifestPaths.find(existsSync)

    if (! foundManifestPath) {
        error(`Unable to find manifest file.`)

        process.exit(1)
    }

    info(`Reading manifest [${foundManifestPath}].`)

    const manifest = JSON.parse(readFileSync(foundManifestPath).toString())

    const manifestFiles = Object.keys(manifest)

    const isSsr = Array.isArray(manifest[manifestFiles[0]])

    isSsr
        ? info(`SSR manifest found.`)
        : info(`Non-SSR manifest found.`)

    const manifestAssets = isSsr
        ? manifestFiles.flatMap(key => manifest[key])
        : manifestFiles.flatMap(key => [
            ...manifest[key].css ?? [],
            manifest[key].file,
        ])

    const assetsPath = argument('assets') ?? dirname(foundManifestPath)+'/assets'

    info(`Verify assets in [${assetsPath}].`)

    const existingAssets = readdirSync(assetsPath, { withFileTypes: true })

    const orphanedAssets = existingAssets.filter(file => file.isFile())
        .filter(file => manifestAssets.findIndex(asset => asset.endsWith(`/${file.name}`)) === -1)

    if (orphanedAssets.length === 0) {
        info(`No ophaned assets found.`)
    } else {
        orphanedAssets.length === 1
            ? info(`[${orphanedAssets.length}] orphaned asset found.`)
            : info(`[${orphanedAssets.length}] orphaned assets found.`)

        orphanedAssets.forEach(asset => {
            const path = `${assetsPath}/${asset.name}`

            option(`dry-run`)
                ? info(`Orphaned asset [${path}] would be removed.`)
                : info(`Removing orphaned asset [${path}].`)

            if (! option(`dry-run`)) {
                unlinkSync(path)
            }
        })
    }
}

main()

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0051 ]--