!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/sync/src/firebase/   drwxr-xr-x
Free 13 GB of 57.97 GB (22.43%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     send_old.js (2.68 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
var admin = require("firebase-admin");
const { MongoClient } = require("mongodb");
const { getNextSequence } = require("../vendorSequence");
var serviceAccount = require("../../serviceAccount.json");

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount)
});

async function getToken(vendor_id) {
  const MONGO_URI = process.env.MONGO_URI;
  const DB_NAME = process.env.MONGO_DB_NAME;
  
  const client = new MongoClient(MONGO_URI);
  await client.connect();
  try {
    const db = client.db(DB_NAME);
    const data = await db.collection("DeviceToken").findOne({"vendor_id":vendor_id.toString()},{"tokens":1});
    return data;
  } catch(err) {
    console.log(err.message);
  }finally {
    await client.close();   
  }
}
// getToken(88000001);
async function sendMessage(payload) {
      try {
        var vendor_id = payload.vendor_id;
        var vendor=await getToken(vendor_id);

        if(!vendor || !vendor.tokens || vendor.tokens.length==0){
          return "no token";
        }        
        var seq = await getNextSequence(vendor_id);
        delete payload.vendor_id;
        payload.sequence = seq;
        payload.type = "sync";
        console.log(payload);
        
          var message = {
            // android: {
            //   priority: 'high',
            //   collapseKey: 'msg_' + Date.now() // Unique key
            // },
            notification: {
              title: "Data Changed",
              body: "NEW DATA ADDED"
            },
            android: {
              priority: 'high'
            },
            data: {
              data: JSON.stringify(payload)
            },
            tokens: vendor.tokens

          };
          await admin.messaging().sendEachForMulticast(message)
          .then(async(response) => {
            if (response.failureCount > 0) {
              const failedTokens = [];
              response.responses.forEach((resp, idx) => {
                if (!resp.success) {
                    // console.log('Failure sending notification to', vendor.tokens[idx], resp.error);  
                //   console.log(idx);
                  failedTokens.push(vendor.tokens[idx]);
                }
              });
              
              console.log('List of tokens that caused failures: ' + response.failureCount);
            }
              console.log(response.successCount + ' messages were sent successfully');
          }).catch((error)=>{
            console.log(error);
          });
          return "done";
      }
      catch (error) {
        console.log("error",error.message);
        return "error";
      }
  }
  module.exports = { sendMessage };

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