!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/beximco/proxy_server-master/controllers/   drwxr-xr-x
Free 13.13 GB of 57.97 GB (22.66%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     proxyController.js (14.34 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
// const isEmpty = require("lodash.isempty");
const axios = require("axios");
require("events").EventEmitter.prototype._maxListeners = 0;

const token =
  "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NCwiaWF0IjoxNjYyNTQ1NjY3LCJleHAiOjE5NzgxMjE2Njd9.5lVlCpiqLqBmdASH-06JubosdJ4jmHwqkepXIkaGr3E";

async function updateCron(machine_id, equipment_id, order_id, factory_id) {
  console.log("Stage 1 Function");
  var cronlogs = await axios.get(
    `http://127.0.0.1:1337/equipments?serial_no=${equipment_id}&status=0&_sort=id:DESC&_limit=1`,
    {
      headers: {
        Authorization: "Bearer " + token,
      },
    }
  );

  if (cronlogs.data.length === 1) {
    console.log("IN LEN");
    if (cronlogs.data[0].status == 0) {
      console.log("IN STATUS");

      var checklogs = await axios.get(
        `http://127.0.0.1:1337/queue?equipment_id=${equipment_id}&status=0&stage=stage 1&_sort=id:DESC&_limit=1`,
        {
          headers: {
            Authorization: "Bearer " + token,
          },
        }
      );

      if (checklogs.data.length > 0) {
        console.log("ALREADY EXISTS");
      } else {
        const logsBody = {
          machine_type: "creel",
          machine_id: machine_id,
          equipment_id: equipment_id,
          equipment_type: "warped_beam",
          order_id: order_id,
          stage: "stage 1",
          factory_id: factory_id,
          process_name: "creeling",
          input: "yarn_bags",
          output: "beam",
          status: 1,
        };
        await axios.post("http://127.0.0.1:1337/queue", logsBody, {
          headers: {
            Authorization: "Bearer " + token,
          },
        });
        await axios.put(
          "http://127.0.0.1:1337/equipments/" + cronlogs.data[0].id,
          {
            status: 1,
          },
          {
            headers: {
              Authorization: "Bearer " + token,
            },
          }
        );
      }
    }
  }
}

async function updateBeam(machine_id, equipment_id, sbeam) {
  // var arr = [
  //   "1111111110",
  //   "1111111111",
  //   "1111111112",
  //   "1111111113",
  //   "1111111114",
  //   "1111111115",
  //   "1111111116",
  //   "1111111117",
  //   "1111111118",
  //   "1111111119",
  // ];
  const arr = equipment_id.split(",");
  console.log(equipment_id);
  console.log("SBEAM :" + sbeam);
  var cronlogs = await axios.get(
    `http://127.0.0.1:1337/equipments?serial_no=${sbeam}&status=0&_sort=id:DESC&_limit=1`,
    {
      headers: {
        Authorization: "Bearer " + token,
      },
    }
  );

  if (cronlogs.data.length === 1) {
    console.log("IN LEN");
    if (cronlogs.data[0].status == 0) {
      console.log("IN STATUS");

      await axios.put(
        "http://127.0.0.1:1337/equipments/" + cronlogs.data[0].id,
        {
          status: 1,
        },
        {
          headers: {
            Authorization: "Bearer " + token,
          },
        }
      );

      if (arr.length > 0) {
        for (let index = 0; index < arr.length; index++) {
          const element = arr[index];
          var queuelogs = await axios.get(
            `http://127.0.0.1:1337/queue?status=0&stage=stage 2&equipment_id=${element}&_sort=id:DESC&_limit=1`,
            {
              headers: {
                Authorization: "Bearer " + token,
              },
            }
          );
          if (queuelogs.data.length > 0) {
            const element_id = queuelogs.data[0];

            await axios.put(
              "http://127.0.0.1:1337/queue/" + element_id.id,
              {
                status: 1,
                machine_id: machine_id,
                machine_type: "warped_beam_creel",
                output_id: sbeam,
              },
              {
                headers: {
                  Authorization: "Bearer " + token,
                },
              }
            );
          }
        }
      }
    }
  }
}

async function updateWeavingLoom(machine_id, equipment_id) {
  var queuelogs = await axios.get(
    `http://127.0.0.1:1337/queue?status=0&stage=stage 3&equipment_id=${equipment_id}`,
    {
      headers: {
        Authorization: "Bearer " + token,
      },
    }
  );

  if (queuelogs.data.length > 0) {
    const element = queuelogs.data[0];

    console.log("IN Stage 3 function");
    await axios.put(
      "http://127.0.0.1:1337/queue/" + element.id,
      {
        status: 1,
        machine_id: machine_id,
        machine_type: "weaving_loom",
      },
      {
        headers: {
          Authorization: "Bearer " + token,
        },
      }
    );
  }
}

async function updateFabricInspection(machine_id, equipment_id) {
  var queuelogs = await axios.get(
    `http://127.0.0.1:1337/queue?status=0&stage=stage 4&equipment_id=${equipment_id}`,
    {
      headers: {
        Authorization: "Bearer " + token,
      },
    }
  );

  if (queuelogs.data.length > 0) {
    console.log("IN LEN");

    const element = queuelogs.data[0];

    console.log("IN STATUS");
    await axios.put(
      "http://127.0.0.1:1337/queue/" + element.id,
      {
        status: 1,
        machine_id: machine_id,
        machine_type: "fabric_inspection",
      },
      {
        headers: {
          Authorization: "Bearer " + token,
        },
      }
    );
  }
}

async function updateSingeing(machine_id, equipment_id, output_id) {
  var cronlogs = await axios.get(
    `http://127.0.0.1:1337/equipments?serial_no=${output_id}&status=0&_sort=id:DESC&_limit=1`,
    {
      headers: {
        Authorization: "Bearer " + token,
      },
    }
  );
  if (cronlogs.data.length === 1) {
    await axios.put(
      "http://127.0.0.1:1337/equipments/" + cronlogs.data[0].id,
      {
        status: 1,
      },
      {
        headers: {
          Authorization: "Bearer " + token,
        },
      }
    );
    var queuelogs = await axios.get(
      `http://127.0.0.1:1337/queue?status=0&stage=stage 5&equipment_id=${equipment_id}`,
      {
        headers: {
          Authorization: "Bearer " + token,
        },
      }
    );

    if (queuelogs.data.length > 0) {
      console.log("IN LEN");
      for (let index = 0; index < queuelogs.data.length; index++) {
        const element = queuelogs.data[index];

        console.log("IN STATUS");
        await axios.put(
          "http://127.0.0.1:1337/queue/" + element.id,
          {
            status: 1,
            machine_id: machine_id,
            machine_type: "singeing",
            output_id: output_id,
          },
          {
            headers: {
              Authorization: "Bearer " + token,
            },
          }
        );
      }
    }
  }
}

async function updateFinishingRolls(machine_id, equipment_id) {
  var queuelogs = await axios.get(
    `http://127.0.0.1:1337/queue?status=0&stage=stage 6&equipment_id=${equipment_id}`,
    {
      headers: {
        Authorization: "Bearer " + token,
      },
    }
  );

  if (queuelogs.data.length > 0) {
    console.log("IN LEN");

    const element = queuelogs.data[0];

    console.log("IN STATUS");
    await axios.put(
      "http://127.0.0.1:1337/queue/" + element.id,
      {
        status: 1,
        machine_id: machine_id,
        machine_type: "scanner",
      },
      {
        headers: {
          Authorization: "Bearer " + token,
        },
      }
    );
  }
}

module.exports = {
  scanner: async (req, res, next) => {
    try {
      if (
        req.query.type == "" ||
        (req.query.type == undefined && req.query.id == "") ||
        req.query.id == undefined
      ) {
        res.status(403).json({
          statusInfo: {
            message: "Wrong Query Parameters",
            statusCode: 403,
          },
        });
      } else {
        console.log(req.query.type);
        if (req.query.type == "check") {
          console.log(new Date());
          console.log(req.query.id);
          var machineStat = await axios.get(
            `http://127.0.0.1:1337/machines?machine_id=${req.query.id}`,
            {
              headers: {
                Authorization: "Bearer " + token,
              },
            }
          );
          console.log(machineStat.data[0].status);
          const status = machineStat.data[0].status == 1 ? true : false;
          res.json({
            statusInfo: {
              message: "Checked Successfully",
              status: status,
              statusCode: 200,
            },
          });
        } else if (req.query.type == "submit") {
          if (
            req.query.equipment_id == "" ||
            req.query.equipment_id == undefined
          ) {
            res.json({
              statusInfo: {
                message: "Incorrect Equipment Parameter Values",
                statusCode: 401,
              },
            });
          } else {
            console.log("SCANNING");
            var machineStat = await axios.get(
              `http://127.0.0.1:1337/machines?machine_id=${req.query.id}`,
              {
                headers: {
                  Authorization: "Bearer " + token,
                },
              }
            );
            console.log(machineStat.data[0]);
            if (machineStat.data[0].status == 1) {
              if (machineStat.data[0].type == 1) {
                console.log("TYPE 1");
                await updateCron(
                  req.query.id,
                  req.query.equipment_id,
                  machineStat.data[0].order_id,
                  machineStat.data[0].factory_id
                );
              } else if (machineStat.data[0].type == 3) {
                console.log("TYPE 3");
                await updateWeavingLoom(req.query.id, req.query.equipment_id);
              } else if (machineStat.data[0].type == 4) {
                console.log("TYPE 4");
                await updateFabricInspection(
                  req.query.id,
                  req.query.equipment_id
                );
              } else if (machineStat.data[0].type == 6) {
                console.log("TYPE 6");
                await updateFinishingRolls(
                  req.query.id,
                  req.query.equipment_id
                );
              }
              res.json({
                statusInfo: {
                  message: "Submitted Successfully",
                  statusCode: 200,
                },
              });
            } else {
              res.json({
                statusInfo: {
                  message: "Machine State Has Changed",
                  statusCode: 200,
                },
              });
            }
          }
        } else {
          res.json({
            statusInfo: {
              message: "Wrong Query Parameters",
              statusCode: 500,
            },
          });
        }
      }
    } catch (err) {
      console.log(err.message);
      res.json({
        statusInfo: {
          message: "Server Problem",
          statusCode: 500,
        },
      });
    }
  },

  scanner2: async (req, res, next) => {
    try {
      if (
        req.query.type == "" ||
        (req.query.type == undefined && req.query.id == "") ||
        req.query.id == undefined
      ) {
        res.status(403).json({
          statusInfo: {
            message: "Wrong Query Parameters",
            statusCode: 403,
          },
        });
      } else {
        console.log(req.query.type);
        if (req.query.type == "check") {
          var machineStat = await axios.get(
            `http://127.0.0.1:1337/machines?machine_id=${req.query.id}`,
            {
              headers: {
                Authorization: "Bearer " + token,
              },
            }
          );
          console.log(machineStat.data[0].status);
          const status = machineStat.data[0].status == 1 ? true : false;
          res.json({
            statusInfo: {
              message: "Checked Successfully",
              status: status,
              statusCode: 200,
            },
          });
        } else if (req.query.type == "submit") {
          if (
            req.query.equipment_id == "" ||
            (req.query.equipment_id == undefined && req.query.beam_id == "") ||
            req.query.beam_id == undefined
          ) {
            res.json({
              statusInfo: {
                message: "Incorrect Equipment Parameter Values",
                statusCode: 401,
              },
            });
          } else {
            console.log("Stage 2:" + req.query.id);
            var machineStat = await axios.get(
              `http://127.0.0.1:1337/machines?machine_id=${req.query.id}`,
              {
                headers: {
                  Authorization: "Bearer " + token,
                },
              }
            );

            if (machineStat.data[0].status == 1) {
              console.log("MACHINE STATUS:" + machineStat.data[0].status);
              if (machineStat.data[0].type == 2) {
                console.log("TYPE 2");
                await updateBeam(
                  req.query.id,
                  req.query.equipment_id,
                  req.query.beam_id
                );
              } else if (machineStat.data[0].type == 5) {
                console.log("TYPE 5");
                await updateSingeing(
                  req.query.id,
                  req.query.equipment_id,
                  req.query.beam_id
                );
              }
              res.json({
                statusInfo: {
                  message: "Submitted Successfully",
                  statusCode: 200,
                },
              });
            } else {
              res.json({
                statusInfo: {
                  message: "Machine State Has Changed",
                  statusCode: 200,
                },
              });
            }
          }
        } else {
          res.json({
            statusInfo: {
              message: "Wrong Query Parameters",
              statusCode: 500,
            },
          });
        }
      }
    } catch (err) {
      console.log(err.message);
      res.json({
        statusInfo: {
          message: "Server Problem",
          statusCode: 500,
        },
      });
    }
  },
};

:: 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.0047 ]--