403Webshell
Server IP : 185.208.173.17  /  Your IP : 87.236.161.98
Web Server : Microsoft-IIS/10.0
System : Windows NT SRV8576125506 10.0 build 26100 (Windows Server 2016) AMD64
User : IUSR ( 0)
PHP Version : 7.4.13
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/inetpub/wwwroot/parsmega.nuxt/node_modules/ipx/dist/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/inetpub/wwwroot/parsmega.nuxt/node_modules/ipx/dist/index.mjs
import Sharp from 'sharp';
import defu from 'defu';
import imageMeta from 'image-meta';
import { parseURL, withLeadingSlash, hasProtocol, joinURL, normalizeURL, parseQuery, withoutLeadingSlash, decode } from 'ufo';
import { resolve, join } from 'path';
import isValidPath from 'is-valid-path';
import { stat, readFile } from 'fs-extra';
import destr from 'destr';
import http from 'http';
import https from 'https';
import fetch from 'node-fetch';
import getEtag from 'etag';
import xss from 'xss';

var Handlers = /*#__PURE__*/Object.freeze({
  __proto__: null,
  get quality () { return quality; },
  get fit () { return fit; },
  get background () { return background; },
  get width () { return width; },
  get height () { return height; },
  get resize () { return resize; },
  get trim () { return trim; },
  get extend () { return extend; },
  get extract () { return extract; },
  get rotate () { return rotate; },
  get flip () { return flip; },
  get flop () { return flop; },
  get sharpen () { return sharpen; },
  get median () { return median; },
  get blur () { return blur; },
  get flatten () { return flatten; },
  get gamma () { return gamma; },
  get negate () { return negate; },
  get normalize () { return normalize; },
  get threshold () { return threshold; },
  get modulate () { return modulate; },
  get tint () { return tint; },
  get grayscale () { return grayscale; },
  get crop () { return crop; },
  get q () { return q; },
  get b () { return b; },
  get w () { return w; },
  get h () { return h; },
  get s () { return s; }
});

function getEnv(name, defaultValue) {
  var _a;
  return (_a = destr(process.env[name])) != null ? _a : defaultValue;
}
function cachedPromise(fn) {
  let p;
  return (...args) => {
    if (p) {
      return p;
    }
    p = Promise.resolve(fn(...args));
    return p;
  };
}
class IPXError extends Error {
}
function createError(message, statusCode) {
  const err = new IPXError(message);
  err.statusMessage = "IPX: " + message;
  err.statusCode = statusCode;
  return err;
}

const createFilesystemSource = (options) => {
  const rootDir = resolve(options.dir);
  return async (id) => {
    const fsPath = resolve(join(rootDir, id));
    if (!isValidPath(id) || id.includes("..") || !fsPath.startsWith(rootDir)) {
      throw createError("Forbidden path:" + id, 403);
    }
    let stats;
    try {
      stats = await stat(fsPath);
    } catch (err) {
      if (err.code === "ENOENT") {
        throw createError("File not found: " + fsPath, 404);
      } else {
        throw createError("File access error for " + fsPath + ":" + err.code, 403);
      }
    }
    if (!stats.isFile()) {
      throw createError("Path should be a file: " + fsPath, 400);
    }
    return {
      mtime: stats.mtime,
      maxAge: options.maxAge || 300,
      getData: cachedPromise(() => readFile(fsPath))
    };
  };
};

const createHTTPSource = (options) => {
  const httpsAgent = new https.Agent({ keepAlive: true });
  const httpAgent = new http.Agent({ keepAlive: true });
  let domains = options.domains || [];
  if (typeof domains === "string") {
    domains = domains.split(",").map((s) => s.trim());
  }
  const hosts = domains.map((domain) => parseURL(domain, "https://").host);
  return async (id) => {
    const parsedUrl = parseURL(id, "https://");
    if (!parsedUrl.host) {
      throw createError("Hostname is missing: " + id, 403);
    }
    if (!hosts.find((host) => parsedUrl.host === host)) {
      throw createError("Forbidden host: " + parsedUrl.host, 403);
    }
    const response = await fetch(id, {
      agent: id.startsWith("https") ? httpsAgent : httpAgent
    });
    if (!response.ok) {
      throw createError(response.statusText || "fetch error", response.status || 500);
    }
    let maxAge = options.maxAge || 300;
    const _cacheControl = response.headers.get("cache-control");
    if (_cacheControl) {
      const m = _cacheControl.match(/max-age=(\d+)/);
      if (m && m[1]) {
        maxAge = parseInt(m[1]);
      }
    }
    let mtime;
    const _lastModified = response.headers.get("last-modified");
    if (_lastModified) {
      mtime = new Date(_lastModified);
    }
    return {
      mtime,
      maxAge,
      getData: cachedPromise(() => response.buffer())
    };
  };
};

function VArg(arg) {
  return destr(arg);
}
function parseArgs(args, mappers) {
  const vargs = args.split("_");
  return mappers.map((v, i) => v(vargs[i]));
}
function getHandler(key) {
  return Handlers[key];
}
function applyHandler(ctx, pipe, handler, argsStr) {
  const args = handler.args ? parseArgs(argsStr, handler.args) : [];
  return handler.apply(ctx, pipe, ...args);
}

const quality = {
  args: [VArg],
  order: -1,
  apply: (context, _pipe, quality2) => {
    context.quality = quality2;
  }
};
const fit = {
  args: [VArg],
  order: -1,
  apply: (context, _pipe, fit2) => {
    context.fit = fit2;
  }
};
const HEX_RE = /^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i;
const SHORTHEX_RE = /^([a-f\d])([a-f\d])([a-f\d])$/i;
const background = {
  args: [VArg],
  order: -1,
  apply: (context, _pipe, background2) => {
    if (!background2.startsWith("#") && (HEX_RE.test(background2) || SHORTHEX_RE.test(background2))) {
      background2 = "#" + background2;
    }
    context.background = background2;
  }
};
const width = {
  args: [VArg],
  apply: (_context, pipe, width2) => {
    return pipe.resize(width2, null);
  }
};
const height = {
  args: [VArg],
  apply: (_context, pipe, height2) => {
    return pipe.resize(null, height2);
  }
};
const resize = {
  args: [VArg, VArg, VArg],
  apply: (context, pipe, width2, height2) => {
    return pipe.resize(width2, height2, {
      fit: context.fit,
      background: context.background
    });
  }
};
const trim = {
  args: [VArg],
  apply: (_context, pipe, threshold2) => {
    return pipe.trim(threshold2);
  }
};
const extend = {
  args: [VArg, VArg, VArg, VArg],
  apply: (context, pipe, top, right, bottom, left) => {
    return pipe.extend({
      top,
      left,
      bottom,
      right,
      background: context.background
    });
  }
};
const extract = {
  args: [VArg, VArg, VArg, VArg],
  apply: (context, pipe, top, right, bottom, left) => {
    return pipe.extend({
      top,
      left,
      bottom,
      right,
      background: context.background
    });
  }
};
const rotate = {
  args: [VArg],
  apply: (_context, pipe, angel) => {
    return pipe.rotate(angel);
  }
};
const flip = {
  args: [],
  apply: (_context, pipe) => {
    return pipe.flip();
  }
};
const flop = {
  args: [],
  apply: (_context, pipe) => {
    return pipe.flop();
  }
};
const sharpen = {
  args: [VArg, VArg, VArg],
  apply: (_context, pipe, sigma, flat, jagged) => {
    return pipe.sharpen(sigma, flat, jagged);
  }
};
const median = {
  args: [VArg, VArg, VArg],
  apply: (_context, pipe, size) => {
    return pipe.median(size);
  }
};
const blur = {
  args: [VArg, VArg, VArg],
  apply: (_context, pipe) => {
    return pipe.blur();
  }
};
const flatten = {
  args: [VArg, VArg, VArg],
  apply: (context, pipe) => {
    return pipe.flatten({
      background: context.background
    });
  }
};
const gamma = {
  args: [VArg, VArg, VArg],
  apply: (_context, pipe, gamma2, gammaOut) => {
    return pipe.gamma(gamma2, gammaOut);
  }
};
const negate = {
  args: [VArg, VArg, VArg],
  apply: (_context, pipe) => {
    return pipe.negate();
  }
};
const normalize = {
  args: [VArg, VArg, VArg],
  apply: (_context, pipe) => {
    return pipe.normalize();
  }
};
const threshold = {
  args: [VArg],
  apply: (_context, pipe, threshold2) => {
    return pipe.threshold(threshold2);
  }
};
const modulate = {
  args: [VArg],
  apply: (_context, pipe, brightness, saturation, hue) => {
    return pipe.modulate({
      brightness,
      saturation,
      hue
    });
  }
};
const tint = {
  args: [VArg],
  apply: (_context, pipe, rgb) => {
    return pipe.tint(rgb);
  }
};
const grayscale = {
  args: [VArg],
  apply: (_context, pipe) => {
    return pipe.grayscale();
  }
};
const crop = extract;
const q = quality;
const b = background;
const w = width;
const h = height;
const s = resize;

const SUPPORTED_FORMATS = ["jpeg", "png", "webp", "avif", "tiff"];
function createIPX(userOptions) {
  const defaults = {
    dir: getEnv("IPX_DIR", "."),
    domains: getEnv("IPX_DOMAINS", []),
    alias: getEnv("IPX_ALIAS", {}),
    sharp: {}
  };
  const options = defu(userOptions, defaults);
  options.alias = Object.fromEntries(Object.entries(options.alias).map((e) => [withLeadingSlash(e[0]), e[1]]));
  const ctx = {
    sources: {}
  };
  if (options.dir) {
    ctx.sources.filesystem = createFilesystemSource({
      dir: options.dir
    });
  }
  if (options.domains) {
    ctx.sources.http = createHTTPSource({
      domains: options.domains
    });
  }
  return function ipx(id, inputOpts = {}) {
    if (!id) {
      throw createError("resource id is missing", 400);
    }
    id = hasProtocol(id) ? id : withLeadingSlash(id);
    for (const base in options.alias) {
      if (id.startsWith(base)) {
        id = joinURL(options.alias[base], id.substr(base.length));
      }
    }
    const modifiers = inputOpts.modifiers || {};
    const getSrc = cachedPromise(() => {
      const source = inputOpts.source || hasProtocol(id) ? "http" : "filesystem";
      if (!ctx.sources[source]) {
        throw createError("Unknown source: " + source, 400);
      }
      return ctx.sources[source](id);
    });
    const getData = cachedPromise(async () => {
      const src = await getSrc();
      const data = await src.getData();
      const meta = imageMeta(data);
      const mFormat = modifiers.f || modifiers.format;
      let format = mFormat || meta.type;
      if (format === "jpg") {
        format = "jpeg";
      }
      if (meta.type === "svg" && !mFormat) {
        return {
          data,
          format: "svg+xml",
          meta
        };
      }
      const animated = modifiers.animated !== void 0 || modifiers.a !== void 0;
      if (animated) {
        format = "webp";
      }
      let sharp = Sharp(data, { animated });
      Object.assign(sharp.options, options.sharp);
      const handlers = Object.entries(inputOpts.modifiers || {}).map(([name, args]) => ({ handler: getHandler(name), name, args })).filter((h) => h.handler).sort((a, b) => {
        const aKey = (a.handler.order || a.name || "").toString();
        const bKey = (b.handler.order || b.name || "").toString();
        return aKey.localeCompare(bKey);
      });
      const handlerCtx = {};
      for (const h of handlers) {
        sharp = applyHandler(handlerCtx, sharp, h.handler, h.args) || sharp;
      }
      if (SUPPORTED_FORMATS.includes(format)) {
        sharp = sharp.toFormat(format, {
          quality: handlerCtx.quality,
          progressive: format === "jpeg"
        });
      }
      const newData = await sharp.toBuffer();
      return {
        data: newData,
        format,
        meta
      };
    });
    return {
      src: getSrc,
      data: getData
    };
  };
}

async function _handleRequest(req, ipx) {
  const res = {
    statusCode: 200,
    statusMessage: "",
    headers: {},
    body: ""
  };
  const url = parseURL(normalizeURL(req.url));
  const params = parseQuery(url.search);
  const id = withoutLeadingSlash(decode(url.pathname || params.id));
  const modifiers = Object.create(null);
  for (const pKey in params) {
    if (pKey === "source" || pKey === "id") {
      continue;
    }
    modifiers[pKey] = params[pKey];
  }
  const img = ipx(id, {
    modifiers,
    source: params.source
  });
  const src = await img.src();
  if (src.mtime) {
    if (req.headers["if-modified-since"]) {
      if (new Date(req.headers["if-modified-since"]) >= src.mtime) {
        res.statusCode = 304;
        return res;
      }
    }
    res.headers["Last-Modified"] = +src.mtime + "";
  }
  if (src.maxAge !== void 0) {
    res.headers["Cache-Control"] = `max-age=${+src.maxAge}, public, s-maxage=${+src.maxAge}`;
  }
  const { data, format } = await img.data();
  const etag = getEtag(data);
  res.headers.ETag = etag;
  if (etag && req.headers["if-none-match"] === etag) {
    res.statusCode = 304;
    return res;
  }
  if (format) {
    res.headers["Content-Type"] = `image/${format}`;
  }
  res.body = data;
  return res;
}
function handleRequest(req, ipx) {
  return _handleRequest(req, ipx).catch((err) => {
    const statusCode = parseInt(err.statusCode) || 500;
    const statusMessage = err.statusMessage ? xss(err.statusMessage) : `IPX Error (${statusCode})`;
    if (process.env.NODE_ENV !== "production" && statusCode === 500) {
      console.error(err);
    }
    return {
      statusCode,
      statusMessage,
      body: statusMessage,
      headers: {}
    };
  });
}
function createIPXMiddleware(ipx) {
  return function IPXMiddleware(req, res) {
    handleRequest({ url: req.url, headers: req.headers }, ipx).then((_res) => {
      res.statusCode = _res.statusCode;
      res.statusMessage = _res.statusMessage;
      for (const name in _res.headers) {
        res.setHeader(name, _res.headers[name]);
      }
      res.end(_res.body);
    });
  };
}

export { createIPX, createIPXMiddleware, handleRequest };

Youez - 2016 - github.com/yon3zu
LinuXploit