Geliştirici Merkezi

TR

apply_import_tlds() - Tüm Uzantıları İçeri Aktar

Yazman üzerinde bulunan tüm uzantıları API üzerinden içeri aktarmak için kullanılır.

Modül klasöründe bulunan “controllers/import-tld.php” dosyası içinde çağırılmaktadır.

Fonksiyonu örnekte olacak şekilde kullanabilirsiniz.

public function apply_import_tlds(){

    $cost_cid           = $this->config["settings"]["cost-currency"]; // Currency ID

    $prices             = $this->cost_prices();
    if(!$prices) return false;

    Helper::Load(["Products","Money"]);

    $profit_rate        = Config::get("options/domain-profit-rate");

    foreach($prices AS $name=>$val){
        $api_cost_prices    = [
            'register' => $val["register"],
            'transfer' => $val["transfer"],
            'renewal'  => $val["renewal"],
        ];

        $paperwork      = 0;
        $epp_code       = 1;
        $dns_manage     = 1;
        $whois_privacy  = 1;
        $module         = $this->config["meta"]["name"];

        $check          = Models::$init->db->select()->from("tldlist")->where("name","=",$name);

        if($check->build()){
            $tld        = $check->getAssoc();
            $pid        = $tld["id"];

            $reg_price = Products::get_price("register","tld",$pid);
            $ren_price = Products::get_price("renewal","tld",$pid);
            $tra_price = Products::get_price("transfer","tld",$pid);

            $tld_cid    = $reg_price["cid"];

            $register_cost  = Money::deformatter($api_cost_prices["register"]);
            $renewal_cost   = Money::deformatter($api_cost_prices["renewal"]);
            $transfer_cost  = Money::deformatter($api_cost_prices["transfer"]);

            // ExChanges
            $register_cost  = Money::exChange($register_cost,$cost_cid,$tld_cid);
            $renewal_cost   = Money::exChange($renewal_cost,$cost_cid,$tld_cid);
            $transfer_cost  = Money::exChange($transfer_cost,$cost_cid,$tld_cid);

            $reg_profit     = Money::get_discount_amount($register_cost,$profit_rate);
            $ren_profit     = Money::get_discount_amount($renewal_cost,$profit_rate);
            $tra_profit     = Money::get_discount_amount($transfer_cost,$profit_rate);

            $register_sale  = $register_cost + $reg_profit;
            $renewal_sale   = $renewal_cost + $ren_profit;
            $transfer_sale  = $transfer_cost + $tra_profit;

            Products::set("domain",$pid,[
                'paperwork'         => $paperwork,
                'epp_code'          => $epp_code,
                'dns_manage'        => $dns_manage,
                'whois_privacy'     => $whois_privacy,
                'register_cost'     => $register_cost,
                'renewal_cost'      => $renewal_cost,
                'transfer_cost'     => $transfer_cost,
                'module'            => $module,
            ]);

            Models::$init->db->update("prices",[
                'amount' => $register_sale,
                'cid'    => $tld_cid,
            ])->where("id","=",$reg_price["id"])->save();

            Models::$init->db->update("prices",[
                'amount' => $renewal_sale,
                'cid'    => $tld_cid,
            ])->where("id","=",$ren_price["id"])->save();

            Models::$init->db->update("prices",[
                'amount' => $transfer_sale,
                'cid'    => $tld_cid,
            ])->where("id","=",$tra_price["id"])->save();

        }
        else{

            $tld_cid    = $cost_cid;

            $register_cost  = Money::deformatter($api_cost_prices["register"]);
            $renewal_cost   = Money::deformatter($api_cost_prices["renewal"]);
            $transfer_cost  = Money::deformatter($api_cost_prices["transfer"]);

            $reg_profit     = Money::get_discount_amount($register_cost,$profit_rate);
            $ren_profit     = Money::get_discount_amount($renewal_cost,$profit_rate);
            $tra_profit     = Money::get_discount_amount($transfer_cost,$profit_rate);

            $register_sale  = $register_cost + $reg_profit;
            $renewal_sale   = $renewal_cost + $ren_profit;
            $transfer_sale  = $transfer_cost + $tra_profit;

            $insert                 = Models::$init->db->insert("tldlist",[
                'status'            => "inactive",
                'cdate'             => DateManager::Now(),
                'name'              => $name,
                'paperwork'         => $paperwork,
                'epp_code'          => $epp_code,
                'dns_manage'        => $dns_manage,
                'whois_privacy'     => $whois_privacy,
                'currency'          => $tld_cid,
                'register_cost'     => $register_cost,
                'renewal_cost'      => $renewal_cost,
                'transfer_cost'     => $transfer_cost,
                'module'            => $module,
            ]);

            if($insert){
                $tld_id         = Models::$init->db->lastID();

                Models::$init->db->insert("prices",[
                    'owner'     => "tld",
                    'owner_id'  => $tld_id,
                    'type'      => 'register',
                    'amount'    => $register_sale,
                    'cid'       => $tld_cid,
                ]);

                Models::$init->db->insert("prices",[
                    'owner'     => "tld",
                    'owner_id'  => $tld_id,
                    'type'      => 'renewal',
                    'amount'    => $renewal_sale,
                    'cid'       => $tld_cid,
                ]);

                Models::$init->db->insert("prices",[
                    'owner'     => "tld",
                    'owner_id' => $tld_id,
                    'type'      => 'transfer',
                    'amount'    => $transfer_sale,
                    'cid'       => $tld_cid,
                ]);
            }

        }
    }
    return true;
}
import_domain() - Alan Adlarını İçeri Aktar

Bir Sorunuz mu Var?

Bize yazmaktan çekinmeyin. En kısa sürede yanıt göndereceğiz.
Bize Ulaşın.
Copyright © 2024. All Rights Reserved.
Join Our Discord Channel
Top