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


Viewing file:     cron.js (8.25 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
'use strict';
// const redis = require("redis");
var { client } = require('../../checking/redisClient');
var uuid = require('uuid-random');
const fs = require('fs');
const utf8 = require('utf8');
const path = require('path');
// const bluebird = require("bluebird");
// bluebird.promisifyAll(redis.RedisClient.prototype);
// bluebird.promisifyAll(redis.Multi.prototype);
module.exports = {
  
  /**
   * Simple example.
   * Every monday at 1am.
   */
  // '0 1 * * 1': () => {
  //
  // }

 


    '*/69 * * * * *': async() => {
        //         client.flushdb( function (err, succeeded) {
        //     console.log(succeeded); // will be true if successfull
        // });
              async function getLastHit() {
          return  new Promise((res, rej) => {  
            return client.exists("last_hit", function(err, reply) {
              if (reply === 1) {
                client.hgetall("last_hit", function (err, object) {
                  // console.log(object);
                  res(object.last_hit);
                  
                });
              }
              else
              {
                res("");
              }   
          }); 
          });   
        }

        async function getLastSubscribeCron() {
          return  new Promise((res, rej) => {  
            return client.exists("subscribe_cron", function(err, reply) {
              if (reply === 1) {
                client.hgetall("subscribe_cron", function (err, object) {
                  // console.log(object);
                  res(object.last_hit);
                  
                });
              }
              else
              {
                res("");
              }   
          }); 
          });   
        }

var last_hit_time=await getLastHit();
var lastSubscribeCron=await getLastSubscribeCron();
// console.log(last_hit_time);

var tim=new Date();
let e_dt= new Date();
e_dt.setSeconds( e_dt.getSeconds() + 2 ); 
tim.setSeconds( tim.getSeconds() -2 ); 

if(last_hit_time <= e_dt.toISOString() && last_hit_time >= tim.toISOString())
{
  console.log("no cron");
  // var user =await strapi.query('user', 'users-permissions').find();
}
else if(lastSubscribeCron <= e_dt.toISOString() && lastSubscribeCron >= tim.toISOString()){
  console.log("no cron because of subscribe cron");
}
else{
  console.log("cron ");

    var user =await strapi.query('user', 'users-permissions').find();
    var services =await strapi.query('service').find();

    

          for (let i = 0; i < services.length; i++) {
            var serviceId=services[i].serviceId;
            var vendor = services[i].vendor.username;
            
            var count= await strapi.query("plugins::billing.records").count({ serviceId: serviceId, vendor: vendor});
            var vendor_total= await strapi.query("plugins::billing.records").count({vendor: vendor});
            // console.log(serviceId+"=="+vendor+"=="+vendor_total);
            var hitData =await strapi.query('hit-Report').find({service: serviceId, vendor: vendor});
            // console.log(serviceId+"=="+vendor+"=="+count+"=="+hitData);
           
            if (hitData.length>0) {
                // var a=await strapi.query('hit-Report').update({vendor: vendor}, {vendorTotal: vendor_total});
                var b=await strapi.query('hit-Report').update({service: serviceId, vendor: vendor}, {totalHit:count,vendorTotal: vendor_total});
               


            } else {
              const data={
                vendor : vendor,
                service : String(serviceId),
                totalHit : parseInt(count),
                vendorTotal: parseInt(vendor_total) 
              };
              await strapi.entityService.create({data},{ model: 'hit-Report' });
             

            }

            // strapi.query('user', 'users-permissions').update({username: vendor}, {total_hit:count});
          }
           user.forEach(users=>{
            var header=users.token;
           
            client.exists(header, function(err, reply) {
              if (reply === 1) {                                
            client.hgetall(header, function (err, object) {
              // console.log(object); // user full information
              if(parseInt(object.m_balance,10)!==parseInt(users.balance,10))
              {
                console.log("if");
                var bal = users.balance-parseInt(object.m_balance,10);
                var r_balance=parseInt(object.r_balance,10)+bal;
                  client.hmset(header, {m_balance:r_balance,r_balance:r_balance});
                   strapi.query('user', 'users-permissions').update({token: header}, {balance:r_balance});
                   
              }
              else{
                console.log(parseFloat(object.r_balance).toFixed(2));
                client.hmset(header, {m_balance:parseFloat(object.r_balance).toFixed(2)});
                strapi.query('user', 'users-permissions').update({token: header}, {balance:parseFloat(object.r_balance).toFixed(2)});

                  }
                });

              } 
            });
          }
          )
              
}


  },
  

     // '56 18 * * *'
    //  '*/69 * * * * *'
    '05 00 * * *': async() => {
      var nowDate = new Date(); 
      if (fs.existsSync('../logs/'+nowDate.getFullYear()+'-'+(nowDate.getMonth()+1)+'-'+(nowDate.getDate()-1)+'.csv')){
        var today   = nowDate.getFullYear()+'-'+(nowDate.getMonth()+1)+'-'+(nowDate.getDate()-1);
        var checkStatus =await strapi.query('subscription-status').find({status:'A', created_at_lt: today});
        console.log(checkStatus.length);
        console.log('exists');
      }else{
    
      var today   = nowDate.getFullYear()+'-'+(nowDate.getMonth()+1)+'-'+(nowDate.getDate()-1);
      var checkStatus =await strapi.query('subscription-status').find({status:'A', created_at_lt: today});

      fs.appendFileSync('../logs/'+nowDate.getFullYear()+'-'+(nowDate.getMonth()+1)+'-'+(nowDate.getDate()-1)+'.csv', nowDate+','+"Subscriber Renew:"+checkStatus.length+'\n\n', 'utf-8', function(err, data) {
        if (err) throw err;
        console.log('Done!');
         });

        
  
        // console.log(services.serviceId+'='+checkStatus.serviceId);
  
          // var header=services;  
          for (let i = 0; i < checkStatus.length; i++) {
            var services =await strapi.query('service').findOne({serviceId:checkStatus[i].serviceId,rate_gt:0});
            var header=services.vendor.token;
            console.log(services.serviceId); 
            // await strapi.query('user', 'users-permissions').update({token: header}, {balance:services.vendor.balance-services.rate});
            client.exists(header, function(err, reply) {
              if (reply === 1) {                                
            client.hgetall(header, function (err, object) {
              // console.log(object.r_balance);
                  client.hmset(header, {r_balance: parseFloat(object.r_balance).toFixed(2)-services.rate});
                  var hit_time=new Date().toISOString();
                  client.hmset("subscribe_cron", {last_hit: hit_time});

                  const data={
                    partner_name : services.partner.name,
                    vendor : services.vendor.username,
                    rate : services.rate,
                    operator : services.operator,
                    keyWord : services.keyWord,
                    serviceId : services.serviceId,
                    tx_id : uuid(),
                    msisdn: checkStatus[i].msisdn,
                    serviceTier: services.serviceTier,
                    billerType: 'CRON',
                    created_at_gmt: nowDate.getFullYear()+'-'+(nowDate.getMonth()+1)+'-'+nowDate.getDate(),
                  };
                  strapi.entityService.create({data},{ model: "plugins::billing.records" });

                });

                fs.appendFileSync('../logs/'+nowDate.getFullYear()+'-'+(nowDate.getMonth()+1)+'-'+(nowDate.getDate()-1)+'.csv', services.serviceId+','+services.keyWord+','+checkStatus[i].msisdn+','+services.rate+'\n', 'utf-8', function(err, data) {
                  if (err) throw err;
                  console.log('Done!');
                   });
          
                  }
      
                });
              } 
        
          
            
          }
        




      
    


        

  
  
  },

  
};

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