404

[ Avaa Bypassed ]




Upload:

Command:

botdev@18.117.252.141: ~ $
<?php
include "AdsManagerDatabase.class.php";
include "ads/Ads.class.php";
include "ads/ImageAds.class.php";
include "ads/HashemiAds.class.php";
include "ads/DiwarAds.class.php";
include "ads/Damnoosh.class.php";
include "ads/ForwardingAd.class.php";
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of AdsManager
 *
 * @author len
 */
class AdsManager extends BaseSerevice {
    //put your code here
    public $TG;
    public $db;
    public $activeAds = array();
    public $testAds = array();
    function __construct(TranslateService $ts) {
        parent::__construct($ts);
        $this->TG = $ts;
        $this->db = new AdsManagerDatabase($this);
        // $this->activeAds[] = new Ads("apprelease");
        // $this->activeAds[] = new HashemiAds("HashemiAdsLieben");
        // $diwarAd = new DiwarAds("3in1DiwarPanahNrw");
        // $damnooshAd = new DamnooshAds("damnoosh1");
        // $diwarAd->setMessageID(84644237)->setFromChatID(44903244);
        //msgid:92340858 from chatID 44903244
        // $damnooshAd->setMessageID(92340858)->setFromChatID(44903244);

        // 84642843 from chatID44903244
        // $diwarAd->setMessageID(83590103)->setFromChatID(44903244);
        // $this->testAds[] =$damnooshAd;
        // $this->testAds[] =$diwarAd2;
        // $this->activeAds[] =$diwarAd;
        // $this->activeAds[] =$diwarAd2;
//        $this->TG->sendMessage($this->activeAds->msg,$this->TG->adminId); 
    }
    function advertise( User $user){
        $success = false;
        foreach($this->activeAds as $ad) {
            if($this->isAdvertised($user, $ad)){
                $alright = "already advertised";
                // $this->TG->sendMessageLog($alright);
                return false;
            }
            else{
                $success = $this->sendAds($user, $ad);
                break; 
            }

        }
        return $success;


        // $this->sendTestAds($user);
    }
    // function isAdFinished(){
    //     return $this->getDB()->isAdFinished();
    // }
    function isAdvertised(User $user, Ads $ad){
        return $this->db->isAdvertised($user->chatId, $ad->id);
    }
    function sendAds(User $user, Ads $ad){
        $ad->setTG($this->TG);
        $result = $ad->send($user);
        if($result == false) {
            $this->TG->db->insertUsersBots($user->chatId,$this->TG->botUsername, 0);
            return false;
        }
        else {
            $this->TG->db->insertUser($user->chatId,"adsuser","adsuser","adsuser",$this->TG->botUsername);
            $this->TG->db->insertUsersBots($user->chatId,$this->TG->botUsername, 1);
            $this->getDB()->insertUserAsAdvertised($user->chatId,$ad->id);
            $this->getDB()->increaseAdsSent($ad->id);
            return true;
        }
    }
    function sendTestAds($user){
        // $user = new User($this->TG->adminId,"user",true, $this->TG->db);
        foreach($this->testAds as $ad) {
                // if($this->TG->isAdmin()){
                    $ad->setTG($this->TG);
                    $ad->forwardTo($user);
                // }
        }
    }
    function fetchActiveAds(){
        $activeAds = $this->getDb()->getActiveAds($this->TG->botUsername);
        foreach( $activeAds as $ad) {
            $forwardingAd = new ForwardingAd($ad);
            $this->activeAds[] = $forwardingAd;
        }
    }
    function groupAdvertise($numberOfPeople){
        $this->fetchActiveAds();
        $this->sendAdvertisements($numberOfPeople);
    }
    function sendAdvertisements($numberOfPeople){
        $numberOfSuccessAds = 0;
        $usersData = $this->getDB()->getSomeNotAdvertisedUsers($numberOfPeople,$this->activeAds[0]->id,$this->TG->botUsername);
        foreach($usersData as  $userData) {
            // $user = new User($this->TG->adminId."2",$userData['role'],false,$this->getDB());
            $user = new User($userData['userid'],$userData['role'],false,$this->getDB());
            
            $success = $this->advertise($user);
            if($success == true){
                $numberOfSuccessAds++;
            }
        }
        $this->TG->sendMessageLog("number of successful ads ".$numberOfSuccessAds);
    }
    function getDB() : AdsManagerDatabase{
        return $this->db;
    }

}

Filemanager

Name Type Size Permission Actions
ads Folder 2755
AdsManager.class.php File 4.32 KB 0755
AdsManagerDatabase.class.php File 3.04 KB 0755