<commit_before><?php

class SimpleOssWrapper implements OssWrapperInterface
{
    public function getUserInfo(User $user){

        if (!Config::exist('oss_url')){
            return false;
        }

        if (Config::get('oss_url') == ''){
            return false;
        }

        $data = file_get_contents(Config::get('oss_url').(strpos(Config::get('oss_url'), '?') > 0 ? '&' : '?' )
            .'mac='.$user->getMac()
            .'&serial_number='.$user->getSerialNumber()
            .'&type='.$user->getStbType()
            .'&locale='.$user->getLocale()
            .'&login='.$user->getLogin()
            .'&portal='.(empty($_SERVER['HTTP_HOST']) ? '' : $_SERVER['HTTP_HOST'])
            .'&verified='.intval($user->isVerified())
            .'&ip='.$user->getIp()
        );

        return $this->parseResult($data, Config::getSafe('strict_oss_url_check', true));
    }

    public function authorize($login, $password){

        if (!Config::exist('oss_url')){
            return false;
        }

        if (Config::get('oss_url') == ''){
            return false;
        }

        $data = file_get_contents(Config::get('oss_url').(strpos(Config::get('oss_url'), '?') > 0 ? '&' : '?' )
            .'login='.$login
            .'&password='.$password
            .'&portal='.(empty($_SERVER['HTTP_HOST']) ? '' : $_SERVER['HTTP_HOST'])
        );

        return $this->parseResult($data, false);
    }

    private function parseResult($data, $strict_check){

        if (!$data){
            return $strict_check ? array('status' => 0) : false;
        }

        $data = json_decode($data, true);

        if (empty($data)){
            return $strict_check ? array('status' => 0) : false;
        }

        if (Mysql::$debug){
            var_dump($data);
        }

        if ($data['status'] != 'OK' && empty($data['results'])){
            return $strict_check ? array('status' => 0) : false;
        }

        if (array_key_exists(0, $data['results'])){
            $info = $data['results'][0];
        }else{
            $info = $data['results'];
        }

        return $info;
    }

    public function registerSTB($mac, $serial_number, $model){
        return true;
    }

    public function getPackagePrice($ext_package_id, $package_id){

        return (float) Mysql::getInstance()<commit_msg>Fix subscription error passing (issue #4920)<commit_after><?php

class SimpleOssWrapper implements OssWrapperInterface
{
    public function getUserInfo(User $user){

        if (!Config::exist('oss_url')){
            return false;
        }

        if (Config::get('oss_url') == ''){
            return false;
        }

        $data = file_get_contents(Config::get('oss_url').(strpos(Config::get('oss_url'), '?') > 0 ? '&' : '?' )
            .'mac='.$user->getMac()
            .'&serial_number='.$user->getSerialNumber()
            .'&type='.$user->getStbType()
            .'&locale='.$user->getLocale()
            .'&login='.$user->getLogin()
            .'&portal='.(empty($_SERVER['HTTP_HOST']) ? '' : $_SERVER['HTTP_HOST'])
            .'&verified='.intval($user->isVerified())
            .'&ip='.$user->getIp()
        );

        return $this->parseResult($data, Config::getSafe('strict_oss_url_check', true));
    }

    public function authorize($login, $password){

        if (!Config::exist('oss_url')){
            return false;
        }

        if (Config::get('oss_url') == ''){
            return false;
        }

        $data = file_get_contents(Config::get('oss_url').(strpos(Config::get('oss_url'), '?') > 0 ? '&' : '?' )
            .'login='.$login
            .'&password='.$password
            .'&portal='.(empty($_SERVER['HTTP_HOST']) ? '' : $_SERVER['HTTP_HOST'])
        );

        return $this->parseResult($data, false);
    }

    private function parseResult($data, $strict_check){

        if (!$data){
            return $strict_check ? array('status' => 0) : false;
        }

        $data = json_decode($data, true);

        if (empty($data)){
            return $strict_check ? array('status' => 0) : false;
        }

        if ($data['status'] != 'OK' && !empty($data['error'])){
            throw new OssDeny($data['error']);
        }

        if (Mysql::$debug){
            var_dump($data);
        }

        if ($data['status'] != 'OK' && empty($data['results'])){
            return $strict_check ? array('status' => 0) : false;
        }

        if (array_key_exists(0, $data['results'])){
            $info = $data['results'][0];
        }else{
            $info = $data['results'];
        }

        return $info;
    }

    public function registerSTB($mac, $serial_number, $model){
        return true;
    }

    public function getPackagePrice($ext_package_id, $package_id){

        return (float) Mysql::getInstance()
{'fraction_non_alphanumeric': 0.19341478566991097, 'fraction_numerical': 0.003727479809484365, 'mean_word_length': 2.163064833005894, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6255129', 'n_tokens_mistral': 1504, 'n_tokens_neox': 1435, 'n_words': 235}