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

Software: Apache. PHP/8.1.30 

uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC
2025 x86_64
 

uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root)  

Safe-mode: OFF (not secure)

/usr/share/nodejs/npm/node_modules/treeverse/lib/   drwxr-xr-x
Free 25.26 GB of 117.98 GB (21.41%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     depth-descent.js (1.7 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
// Perform a depth-first walk of a tree, ONLY doing the descent (visit)
//
// This uses a stack rather than recursion, so that it can handle deeply
// nested trees without call stack overflows.  (My kingdom for proper TCO!)
//
// This is only used for cases where leave() is not specified.
//
// a
// +-- b
// |   +-- 1
// |   +-- 2
// +-- c
//     +-- 3
//     +-- 4
//
// Expect:
// visit a
// visit b
// visit 1
// visit 2
// visit c
// visit 3
// visit 4
//
// stack.push(tree)
// while stack not empty
//   pop T from stack
//   VISIT(T)
//   get children C of T
//   push each C onto stack

const depth = ({
  visit,
  filter,
  getChildren,
  tree,
}) => {
  const stack = []
  const seen = new Map()

  const next = () => {
    while (stack.length) {
      const node = stack.pop()
      const res = visitNode(node)
      if (isPromise(res)) {
        return res.then(() => next())
      }
    }
    return seen.get(tree)
  }

  const visitNode = (tree) => {
    if (seen.has(tree))
      return seen.get(tree)

    seen.set(tree, null)
    const res = visit ? visit(tree) : tree
    if (isPromise(res)) {
      const fullResult = res.then(res => {
        seen.set(tree, res)
        return kidNodes(tree)
      })
      seen.set(tree, fullResult)
      return fullResult
    } else {
      seen.set(tree, res)
      return kidNodes(tree)
    }
  }

  const kidNodes = (tree) => {
    const kids = getChildren(tree, seen.get(tree))
    return isPromise(kids) ? kids.then(processKids) : processKids(kids)
  }

  const processKids = (kids) => {
    kids = (kids || []).filter(filter)
    stack.push(...kids)
  }

  stack.push(tree)
  return next()
}

const isPromise = p => p && typeof p.then === 'function'

module.exports = depth

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

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

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