Function getMsisdn

@author: 713uk13m <dev@nguyenanhung.com>
@time  : 10/7/18 08:57

@return bool|null|string
162557
public function getMsisdn()
    {
        try {
            $phoneTelcoDetectByIp = new PhoneDetectByIp($this->options);
            $this->debug->debug(__FUNCTION__, 'PhoneDetectByIp: ' . json_encode($phoneTelcoDetectByIp));
            if ($phoneTelcoDetectByIp->isMobifone(TRUE)) {
                $msisdn = $this->getRawMsisdn();
                $this->debug->info(__FUNCTION__, 'MSISDN: ' . json_encode($msisdn));
            } elseif ($phoneTelcoDetectByIp->isVinaphone(TRUE)) {
                $msisdn = $this->getRawMsisdn();
                $this->debug->info(__FUNCTION__, 'MSISDN: ' . json_encode($msisdn));
            } else {
                $msisdn = NULL;
                $this->debug->info(__FUNCTION__, 'MSISDN is NULL');
            }

            return $msisdn;
        }
        catch (\Exception $e) {
            $message = 'Error File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Code: ' . $e->getCode() . ' - Message: ' . $e->getMessage();
            $this->debug->error(__FUNCTION__, $message);

            return NULL;
        }
    }
1114352
public function getFullPath()
    {
        if ($this->Filename) {
            return DMS::inst()->getStoragePath() . DIRECTORY_SEPARATOR
                . $this->Folder . DIRECTORY_SEPARATOR . $this->Filename;
        }

        return null;
    }
601904
function getmicrotime() {
		if (function_exists('gettimeofday')) {
			$tod = gettimeofday();
			$sec = $tod['sec'];
			$usec = $tod['usec'];
		} else {
			$sec = time();
			$usec = 0;
		}
		return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec);
	}
994830
public function getDsn()
    {
        if (!$this->config) {
            return '';
        }
        $dsn = array();

        if ($this->config->getHost()) {
            $dsn[] = 'host='.$this->config->getHost();
        }

        if ($this->config->getPort()) {
            $dsn[] = 'port='.$this->config->getPort();
        }

        if ($this->config->getName()) {
            $dsn[] = 'dbname='.$this->config->getName();
        }

        if ($this->config->getUser()) {
            $dsn[] = 'user='.$this->config->getUser();
        }

        if ($this->config->getPass()) {
            $dsn[] = 'password='.$this->config->getPass();
        }

        return $this->getPrefix().implode(';', $dsn);
    }
501757
public static function getSysDomain()
    {
        static $ret = null;

        if ($ret !== null) {
            return $ret;
        }

        $host    = Typo3GeneralUtility::getIndpEnv('HTTP_HOST');
        $rootPid = self::getRootPid();

        $query = 'SELECT *
                    FROM sys_domain
                   WHERE pid = ' . (int)$rootPid . '
                     AND domainName = ' . DatabaseUtility::quote($host, 'sys_domain') . '
                     AND hidden = 0';
        $ret   = DatabaseUtility::getRow($query);

        return $ret;
    }
977465
public function getRawMsisdn()
    {
        try {
            $vn_telco_msisdn_header = Repository\DataRepository::getData('vn_telco_msisdn_header');
            $this->debug->debug(__FUNCTION__, 'MSISDN Header Key', $vn_telco_msisdn_header);
            foreach ($vn_telco_msisdn_header as $key) {
                if (array_key_exists($key, $_SERVER) === TRUE) {
                    foreach (explode(',', $_SERVER[$key]) as $key => $msisdn) {
                        $this->debug->info(__FUNCTION__, 'MSISDN Key: ' . json_encode($key));
                        $this->debug->info(__FUNCTION__, 'MSISDN Value: ' . json_encode($msisdn));

                        return trim($msisdn);
                    }
                }
            }

            return FALSE;
        }
        catch (\Exception $e) {
            $message = 'Error File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Code: ' . $e->getCode() . ' - Message: ' . $e->getMessage();
            $this->debug->error(__FUNCTION__, $message);

            return NULL;
        }
    }
334516
public function chanCidDNID()
    {
        try
        {
            return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_CID_DNID );
        }
        catch( \Cityware\Snmp\Exception $e )
        {
            return null;
        }
    }
212356
protected function getId()
  {
    if($this->currObj instanceof Server)
    {
      return "ts3_s" . $this->currObj->virtualserver_id;
    }
    elseif($this->currObj instanceof Channel)
    {
      return "ts3_c" . $this->currObj->cid;
    }
    elseif($this->currObj instanceof Client)
    {
      return "ts3_u" . $this->currObj->clid;
    }

    return FALSE;
  }
817126
public function isHidden($msisdn = '')
    {
        if (empty($msisdn)) {
            return TRUE;
        }
        if (mb_strpos($msisdn, '*')) {
            return TRUE;
        }
        if (mb_strpos($msisdn, 'x')) {
            return TRUE;
        }

        return FALSE;
    }
884070
protected function getDSN():string {
		$dsn = $this->drivername.':dbname=';

		if($this->options->host !== null){
			$dsn .= $this->options->host;

			if(is_numeric($this->options->port)){
				$dsn .= '/'.$this->options->port;
			}

			$dsn .= ':';
		}

		$dsn .= $this->options->database;

		if($this->options->firebird_encoding !== null){
			$dsn .= ';encoding='.$this->options->firebird_encoding;
		}

		return $dsn;
	}
160885
public function buildServerString() {
		$serverName = env('SERVER_NAME') ?: gethostname();
		if (!$serverName) {
			$user = env('USER');
			$logName = env('LOGNAME');
			if ($user || $logName) {
				$serverName = $user . '@' . $logName;
			}
		}

		return $serverName ?: null;
	}
88166
public function getInfo($msisdn = '')
    {
        try {
            $inputParams = [
                'msisdn' => $msisdn
            ];
            $this->debug->info(__FUNCTION__, 'Input Params: ' . json_encode($inputParams));
            // Sử dụng API: /api/v1/utils/users-get-info.html
            $getInfoUrl       = $this->hostname . $this->config[self::API_GET_INFO]['path'];
            $getInfoToken     = $this->config[self::API_GET_INFO]['token'];
            $getInfoPrefix    = $this->config[self::API_GET_INFO]['prefix'];
            $getInfoSignature = md5($msisdn . $getInfoPrefix . $getInfoToken);
            $getInfoParams    = [
                'msisdn'    => $msisdn,
                'signature' => $getInfoSignature
            ];
            $this->debug->debug(__FUNCTION__, '$getInfoUrl: ' . json_encode($getInfoUrl));
            $this->debug->debug(__FUNCTION__, '$getInfoToken: ' . json_encode($getInfoToken));
            $this->debug->debug(__FUNCTION__, '$getInfoPrefix: ' . json_encode($getInfoPrefix));
            $this->debug->debug(__FUNCTION__, '$getInfoSignature: ' . json_encode($getInfoSignature));
            $this->debug->debug(__FUNCTION__, '$getInfoParams: ' . json_encode($getInfoParams));
            $getInfoRequest = $this->requests->sendRequest($getInfoUrl, $getInfoParams);
            $this->debug->info(__FUNCTION__, '$getInfoRequest: ' . json_encode($getInfoRequest));
            if ($getInfoRequest !== NULL) {
                return json_decode(trim($getInfoRequest));
            } else {
                $this->debug->warning(__FUNCTION__, 'Request Response is Empty');

                return FALSE;
            }
        }
        catch (\Exception $e) {
            $message = 'Error File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Code: ' . $e->getCode() . ' - Message: ' . $e->getMessage();
            $this->debug->error(__FUNCTION__, $message);

            return NULL;
        }
    }
738887
protected function getDsn()
    {
        $dsn = sprintf('%s:', $this->database_driver);

        switch($this->database_driver) {
            case self::SI_DRIVER_SQLITE3:
                $dsn .= $this->database_file;
                break;

            case self::SI_DRIVER_MYSQL:
            case self::SI_DRIVER_PGSQL:
                if (empty($this->database_host)) {
                    throw new Exception('Securimage::database_host is not set');
                } else if (empty($this->database_name)) {
                    throw new Exception('Securimage::database_name is not set');
                }

                $dsn .= sprintf('host=%s;dbname=%s',
                                $this->database_host,
                                $this->database_name);
                break;

        }

        return $dsn;
    }
896745
function getDN($format = FILE_X509_DN_ARRAY, $dn = NULL)
    {
        if (!isset($dn)) {
            $dn = isset($this->currentCert['tbsCertList']) ? $this->currentCert['tbsCertList']['issuer'] : $this->dn;
        }

        switch ((int) $format) {
            case FILE_X509_DN_ARRAY:
                return $dn;
            case FILE_X509_DN_ASN1:
                $asn1 = new File_ASN1();
                $asn1->loadOIDs($this->oids);
                $filters = array();
                $filters['rdnSequence']['value'] = array('type' => FILE_ASN1_TYPE_UTF8_STRING);
                $asn1->loadFilters($filters);
                return $asn1->encodeDER($dn, $this->Name);
            case FILE_X509_DN_OPENSSL:
                $dn = $this->getDN(FILE_X509_DN_STRING, $dn);
                if ($dn === false) {
                    return false;
                }
                $attrs = preg_split('#((?:^|, *|/)[a-z][a-z0-9]*=)#i', $dn, -1, PREG_SPLIT_DELIM_CAPTURE);
                $dn = array();
                for ($i = 1; $i < count($attrs); $i += 2) {
                    $prop = trim($attrs[$i], ', =/');
                    $value = $attrs[$i + 1];
                    if (!isset($dn[$prop])) {
                        $dn[$prop] = $value;
                    } else {
                        $dn[$prop] = array_merge((array) $dn[$prop], array($value));
                    }
                }
                return $dn;
            case FILE_X509_DN_CANON:
                //  No SEQUENCE around RDNs and all string values normalized as
                // trimmed lowercase UTF-8 with all spacing  as one blank.
                $asn1 = new File_ASN1();
                $asn1->loadOIDs($this->oids);
                $filters = array();
                $filters['value'] = array('type' => FILE_ASN1_TYPE_UTF8_STRING);
                $asn1->loadFilters($filters);
                $result = '';
                foreach ($dn['rdnSequence'] as $rdn) {
                    foreach ($rdn as &$attr) {
                        if (is_array($attr['value'])) {
                            foreach ($attr['value'] as $type => $v) {
                                $type = array_search($type, $asn1->ANYmap, true);
                                if ($type !== false && isset($asn1->stringTypeSize[$type])) {
                                    $v = $asn1->convert($v, $type);
                                    if ($v !== false) {
                                        $v = preg_replace('/\s+/', ' ', $v);
                                        $attr['value'] = strtolower(trim($v));
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    $result .= $asn1->encodeDER($rdn, $this->RelativeDistinguishedName);
                }
                return $result;
            case FILE_X509_DN_HASH:
                $dn = $this->getDN(FILE_X509_DN_CANON, $dn);
                if (!class_exists('Crypt_Hash')) {
                    require_once('Crypt/Hash.php');
                }
                $hash = new Crypt_Hash('sha1');
                $hash = $hash->hash($dn);
                extract(unpack('Vhash', $hash));
                return strtolower(bin2hex(pack('N', $hash)));
        }

        // Defaut is to return a string.
        $start = true;
        $output = '';
        $asn1 = new File_ASN1();
        foreach ($dn['rdnSequence'] as $field) {
            $prop = $field[0]['type'];
            $value = $field[0]['value'];

            $delim = ', ';
            switch ($prop) {
                case 'id-at-countryName':
                    $desc = 'C=';
                    break;
                case 'id-at-stateOrProvinceName':
                    $desc = 'ST=';
                    break;
                case 'id-at-organizationName':
                    $desc = 'O=';
                    break;
                case 'id-at-organizationalUnitName':
                    $desc = 'OU=';
                    break;
                case 'id-at-commonName':
                    $desc = 'CN=';
                    break;
                case 'id-at-localityName':
                    $desc = 'L=';
                    break;
                case 'id-at-surname':
                    $desc = 'SN=';
                    break;
                case 'id-at-uniqueIdentifier':
                    $delim = '/';
                    $desc = 'x500UniqueIdentifier=';
                    break;
                default:
                    $delim = '/';
                    $desc = preg_replace('#.+-([^-]+)$#', '$1',  $prop) . '=';
            }

            if (!$start) {
                $output.= $delim;
            }
            if (is_array($value)) {
                foreach ($value as $type => $v) {
                    $type = array_search($type, $asn1->ANYmap, true);
                    if ($type !== false && isset($asn1->stringTypeSize[$type])) {
                        $v = $asn1->convert($v, $type);
                        if ($v !== false) {
                            $value = $v;
                            break;
                        }
                    }
                }
                if (is_array($value)) {
                    $value = array_pop($value); // Always strip data type.
                }
            }
            $output.= $desc . $value;
            $start = false;
        }

        return $output;
    }
865945
private function getIfModifiedSinceTimestamp()
    {
        if (!empty($_SERVER[self::HTTP_IF_MODIFIED_SINCE])) {
            $modifiedSinceString = $_SERVER[self::HTTP_IF_MODIFIED_SINCE];
        } elseif (!empty($_ENV[self::HTTP_IF_MODIFIED_SINCE])) {
            $modifiedSinceString = $_ENV[self::HTTP_IF_MODIFIED_SINCE];
        } else {
            $modifiedSinceString = null;
        }

        if ($modifiedSinceString) {
            // Some versions of IE 6 append "; length=##"
            if (($pos = strpos($modifiedSinceString, ';')) !== false) {
                $modifiedSinceString = substr($modifiedSinceString, 0, $pos);
            }

            return strtotime($modifiedSinceString);
        }

        return false;
    }
215750
function getLastMessage() {
        if(!empty($this->lastMessageID) && $this->messages->has($this->lastMessageID)) {
            return $this->messages->get($this->lastMessageID);
        }
        
        return null;
    }
511131
public function getMessage()
    {
        return isset($this->data['ErrorMsg']) && !empty($this->data['ErrorMsg']) ? $this->data['ErrorMsg'] : null;
    }