Example #1
0
 public function Open()
 {
     #-------------------------------------------------------------------------------
     $Settings = $this->Settings;
     #-------------------------------------------------------------------------------
     $Address = SPrintF('%s:%u', $Settings['Server'], $Settings['Port']);
     #-------------------------------------------------------------------------------
     $this->Link = @MySQL_Connect($Address, $User = $Settings['User'], $Settings['Password'], TRUE);
     #-------------------------------------------------------------------------------
     if (!Is_Resource($this->Link)) {
         return ERROR | @Trigger_Error(SPrintF('[MySQL->Open]: не возможно соединиться с (%s@%s)', $User, $Address));
     }
     #-------------------------------------------------------------------------------
     Debug(SPrintF('[MySQL->Open]: связь как (%s@%s) установлена', $User, $Address));
     #-------------------------------------------------------------------------------
     $Init = System_XML('config/MySqlInit.xml');
     #-------------------------------------------------------------------------------
     if (Is_Error($Init)) {
         return ERROR | @Trigger_Error('[MySQL->Open]: не возможно загрузить запросы инициализации');
     }
     #-------------------------------------------------------------------------------
     foreach ($Init as $Query) {
         if (Is_Error($this->Query($Query))) {
             return ERROR | @Trigger_Error('[MySQL->Open]: не удалось произвести инициализацию подключения');
         }
     }
     #-------------------------------------------------------------------------------
     return TRUE;
     #-------------------------------------------------------------------------------
 }
Example #2
0
function &Messages()
{
    #-----------------------------------------------------------------------------
    $Name = Md5('Messages');
    #-----------------------------------------------------------------------------
    if (!isset($GLOBALS[$Name])) {
        #---------------------------------------------------------------------------
        $GLOBALS[$Name] = System_XML('config/Messages.xml');
        if (Is_Error($GLOBALS[$Name])) {
            return ERROR | Trigger_Error('[Messages]: не удалось загрузить файл сообщений');
        }
    }
    #-----------------------------------------------------------------------------
    return $GLOBALS[$Name];
}
Example #3
0
function &Regulars()
{
    #-----------------------------------------------------------------------------
    $Name = Md5('Regulars');
    #-----------------------------------------------------------------------------
    if (!isset($GLOBALS[$Name])) {
        #---------------------------------------------------------------------------
        $GLOBALS[$Name] = System_XML('config/Regulars.xml');
        if (Is_Error($GLOBALS[$Name])) {
            return ERROR | Trigger_Error('[Regulars]: не удалось загрузить файл регулярных выражений');
        }
    }
    #-----------------------------------------------------------------------------
    return $GLOBALS[$Name];
}
Example #4
0
function &Config()
{
    #-------------------------------------------------------------------------------
    $Name = Md5('Config');
    #-------------------------------------------------------------------------------
    if (!isset($GLOBALS[$Name])) {
        #-------------------------------------------------------------------------------
        $GLOBALS[$Name] = System_XML('config/Config.xml');
        if (Is_Error($GLOBALS[$Name])) {
            return ERROR | Trigger_Error('[Config]: не удалось загрузить основную конфигурацию');
        }
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    return $GLOBALS[$Name];
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
}
Example #5
0
if (Is_Error($DOM->Load('Window'))) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
$DOM->AddText('Title', 'Новое обсуждение');
#-------------------------------------------------------------------------------
$Table = array();
#-------------------------------------------------------------------------------
$Comp = Comp_Load('Form/Input', array('name' => 'Theme', 'size' => 60, 'type' => 'text'));
if (Is_Error($Comp)) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
$Table[] = array('Тема обсуждения', $Comp);
#-------------------------------------------------------------------------------
$Smiles = System_XML('config/Smiles.xml');
if (Is_Error($Smiles)) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
$Options = array('NO' => 'Не выбран');
#-------------------------------------------------------------------------------
foreach ($Smiles as $Smile) {
    $Options[$Smile['Pattern']] = $Smile['Name'];
}
#-------------------------------------------------------------------------------
$Comp = Comp_Load('Form/Select', array('name' => 'Smile', 'onchange' => "if(value != 'NO'){ form.Message.value += value; }"), $Options);
if (Is_Error($Comp)) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
Example #6
0
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
for ($i = 0; $i < $Count; $i += 100) {
    #-------------------------------------------------------------------------------
    $Users = DB_Select('Users', array('*'), array('Limits' => array('Start' => $i, 'Length' => 100)));
    #-------------------------------------------------------------------------------
    switch (ValueOf($Users)) {
        case 'error':
            return ERROR | @Trigger_Error(500);
        case 'exception':
            # No more...
            break;
        case 'array':
            #-------------------------------------------------------------------------------
            $Template = System_XML('xml/Params/Users.xml');
            if (Is_Error($Template)) {
                return new gException('ERROR_TEMPLATE_LOAD', 'Ошибка загрузки шаблона');
            }
            #-------------------------------------------------------------------------------
            #-------------------------------------------------------------------------------
            foreach ($Users as $User) {
                #-------------------------------------------------------------------------------
                $Attribs = @$User['Params']['Settings'];
                #-------------------------------------------------------------------------------
                foreach (Array_Keys($Template['Settings']) as $AttribID) {
                    if (!isset($Attribs[$AttribID])) {
                        $Attribs[$AttribID] = $Template['Settings'][$AttribID]['Value'];
                    }
                }
                #-------------------------------------------------------------------------------
Example #7
0
         default:
             return ERROR | @Trigger_Error(101);
     }
     #-------------------------------------------------------------------------------
     foreach ($DomainSchemes as $DomainScheme) {
         if (isset($DomainScheme['ID'])) {
             $Zones[$DomainScheme['ID']] = array('Name' => $DomainScheme['Name'], 'CostOrder' => $DomainScheme['CostOrder']);
         }
     }
     #-------------------------------------------------------------------------------
 }
 #-------------------------------------------------------------------------------
 #-------------------------------------------------------------------------------
 if (!$Settings['IsSchemesOnly'] || SizeOf($Zones) == 0) {
     #-------------------------------------------------------------------------------
     $DomainZones = System_XML('config/DomainZones.xml');
     if (Is_Error($DomainZones)) {
         return ERROR | @Trigger_Error(500);
     }
     #-------------------------------------------------------------------------------
     foreach ($DomainZones as $DomainZone) {
         $Zones[$DomainZone['Name']] = array('Name' => $DomainZone['Name'], 'CostOrder' => '-');
     }
     #-------------------------------------------------------------------------------
 }
 #-------------------------------------------------------------------------------
 #-------------------------------------------------------------------------------
 $Row = $Scripts = $JsonOut = array();
 #-------------------------------------------------------------------------------
 foreach (array('Название домена', 'Статус', 'Цена в год', 'Сделать заказ') as $Text) {
     $Row[] = new Tag('TD', array('class' => 'Head'), $Text);
Example #8
0
     $IsDelete = DB_Delete('Contracts', array('ID' => $Contract['ID']));
     if (Is_Error($IsDelete)) {
         return ERROR | @Trigger_Error(500);
     }
     #-----------------------------------------------------------------------
     continue;
 }
 #-------------------------------------------------------------------------
 $Profiles = DB_Select('Profiles', '*', array('Where' => SPrintF("`UserID` = %u AND `TemplateID` = 'Natural'", $Contract['UserID'])));
 #-------------------------------------------------------------------------
 switch (ValueOf($Profiles)) {
     case 'error':
         return ERROR | @Trigger_Error(500);
     case 'exception':
         #---------------------------------------------------------------------
         $Template = System_XML('profiles/Natural.xml');
         if (Is_Error($Template)) {
             return ERROR | @Trigger_Error(500);
         }
         #---------------------------------------------------------------------
         $Params = $Template['Attribs'];
         #---------------------------------------------------------------------
         $Attribs = array();
         #---------------------------------------------------------------------
         foreach (Array_Keys($Params) as $ParamID) {
             $Attribs[$ParamID] = $Params[$ParamID]['Value'];
         }
         #---------------------------------------------------------------------
         $Name = Explode(' ', $User['Name']);
         #---------------------------------------------------------------------
         $Attribs['Name'] = Current($Name);
Example #9
0
$__args_list = array('TemplateID', 'Addition');
eval(COMP_INIT);
$Chain = array();
$PatternID = $TemplateID;
do {
    $Pattern = System_XML(SPrintF('tables/%s.xml', $PatternID));
    if (Is_Error($Pattern)) {
        return ERROR | @Trigger_Error(500);
    }
    Array_UnShift($Chain, $Pattern);
    $PatternID = isset($Pattern['RootID']) ? $Pattern['RootID'] : FALSE;
} while ($PatternID);
if (!Is_Null($Addition)) {
    $Chain[] = $Addition;
}
$Template = System_XML('tables/Common.xml');
if (Is_Error($Template)) {
    return ERROR | @Trigger_Error(500);
}
foreach ($Chain as $Pattern) {
    if (isset($Pattern['Cut'])) {
        Array_Cut($Template, $Pattern['Cut']);
    }
    Array_Union($Template, $Pattern);
}
$Columns =& $Template['Columns'];
foreach (Array_Keys($Columns) as $ColumnID) {
    $Column = $Template['Column'];
    $Add = $Column['Add'];
    if (isset($Column['Cut'])) {
        Array_Cut($Add, $Column['Cut']);
Example #10
0
             }
         }
     }
 }
 #-------------------------------------------------------------------------
 if (isset($User['Profiles'])) {
     #-----------------------------------------------------------------------
     $Profiles = $User['Profiles'];
     #-----------------------------------------------------------------------
     $Profiles = Is_Array($Profiles) ? $Profiles : array();
     #-----------------------------------------------------------------------
     foreach ($Profiles as $Profile) {
         #---------------------------------------------------------------------
         $pAttribs = (array) $Profile['Attribs'];
         #---------------------------------------------------------------------
         $Template = System_XML(SPrintF('profiles/%s.xml', $Profile['TemplateID']));
         if (Is_Error($Template)) {
             return ERROR | @Trigger_Error(500);
         }
         #---------------------------------------------------------------------
         $tAttribs = $Template['Attribs'];
         #---------------------------------------------------------------------
         foreach (Array_Keys($tAttribs) as $AttribID) {
             #-------------------------------------------------------------------
             if (!isset($pAttribs[$AttribID])) {
                 $pAttribs[$AttribID] = $tAttribs[$AttribID]['Value'];
             }
         }
         #---------------------------------------------------------------------
         $Replace = Array_ToLine($pAttribs, '%');
         #---------------------------------------------------------------------
Example #11
0
function DB_Types($Row, $ActionID = 'Compress')
{
    /******************************************************************************/
    $__args_types = array('array', 'string');
    #-------------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /******************************************************************************/
    $Types = System_XML('config/TypesDB.xml');
    if (!Is_Error($Types)) {
        #-------------------------------------------------------------------------------
        foreach (Array_Keys($Types) as $ColumnID) {
            #-------------------------------------------------------------------------------
            $Type = $Types[$ColumnID];
            #-------------------------------------------------------------------------------
            if (!isset($Row[$ColumnID])) {
                continue;
            }
            #-------------------------------------------------------------------------------
            $Column =& $Row[$ColumnID];
            #-------------------------------------------------------------------------------
            if (Is_Null($Column)) {
                continue;
            }
            #-------------------------------------------------------------------------------
            $Column = Comp_Load(SPrintF('Formats/%s/%s', $ActionID, $Type), $Column);
            if (Is_Error($Column)) {
                return ERROR | @Trigger_Error('[DB_Types]: не удалось отформатировать значение');
            }
            #-------------------------------------------------------------------------------
        }
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    return $Row;
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
}
Example #12
0
function Wizard_ToString($Amount, $Base = 'RUR')
{
    /****************************************************************************/
    $__args_types = array('double', 'string', 'string');
    #-----------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /****************************************************************************/
    $Base = System_XML(SPrintF('config/%s.xml', $Base));
    if (Is_Error($Base)) {
        return ERROR | @Trigger_Error('[Wizard_ToString]: не удалось загрузить шаблоны');
    }
    #-----------------------------------------------------------------------------
    $Discharges = $Base['Discharges'];
    #-----------------------------------------------------------------------------
    $Result = array();
    #-----------------------------------------------------------------------------
    $j = 0;
    #-----------------------------------------------------------------------------
    $Integer = (int) $Amount;
    #-----------------------------------------------------------------------------
    while ($Integer > 0) {
        #---------------------------------------------------------------------------
        $Section = array();
        #---------------------------------------------------------------------------
        $Discharge = $Discharges[SPrintF('ID%u', $j++)];
        #---------------------------------------------------------------------------
        $Integer = $Integer / $Base['Separate'];
        #---------------------------------------------------------------------------
        $String = SPrintF(SPrintF('%%0%uu', StrLen($Base['Separate']) - 1), (string) Round(($Integer - (int) $Integer) * 1000));
        #---------------------------------------------------------------------------
        $Char0 = $String[0];
        $Char1 = $String[1];
        $Char2 = $String[2];
        #---------------------------------------------------------------------------
        $Digit = $Char0;
        #---------------------------------------------------------------------------
        if ($Digit) {
            $Section[] = $Discharge[SPrintF('ID%u', $Digit)]['ID2'];
        }
        #---------------------------------------------------------------------------
        $Digit = SPrintF('%s%s', $Char1, $Char2);
        #---------------------------------------------------------------------------
        $IsSimple = $Digit < 20 && $Digit > 10;
        #---------------------------------------------------------------------------
        $Digit = $Char1;
        #---------------------------------------------------------------------------
        if ($Digit) {
            $Section[] = $Discharge[$IsSimple ? SPrintF('ID%u', $Char2) : SPrintF('ID%u', $Digit)][$IsSimple ? 'ID3' : 'ID1'];
        }
        #---------------------------------------------------------------------------
        if (!$IsSimple) {
            #-------------------------------------------------------------------------
            $Digit = $Char2;
            #-------------------------------------------------------------------------
            if ($Digit) {
                $Section[] = $Discharge[SPrintF('ID%s', $Digit)]['ID0'];
            }
        }
        #---------------------------------------------------------------------------
        $Section[] = $Discharge[SPrintF('ID%u', $String[2])][SPrintF('ID%u', 9 - ($IsSimple ? -1 : 2))];
        #---------------------------------------------------------------------------
        Array_UnShift($Result, Implode(' ', $Section));
        #---------------------------------------------------------------------------
        $Integer = (int) $Integer;
    }
    #-----------------------------------------------------------------------------
    return SPrintF('%s %02u %s', Implode(' ', $Result), Round(($Amount - (int) $Amount) * 100), $Base['Residue']);
}
Example #13
0
#-------------------------------------------------------------------------------
$Table[] = array('Протокол', $Server['Protocol']);
#-------------------------------------------------------------------------------
$Table[] = array('Адрес сервера', $Server['Address']);
#-------------------------------------------------------------------------------
$Table[] = array('Порт', $Server['Port']);
#-------------------------------------------------------------------------------
$Table[] = array('Логин', $Server['Login']);
#-------------------------------------------------------------------------------
# TODO проверять опцию конфига - показывать или нет
#$Table[] = Array('Пароль',$Server['Password']);
$Table[] = array('Пароль', $Settings['PasswordShow'] ? $Server['Password'] : '******');
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$Template = System_XML(SPrintF('servers/%s.xml', $Server['TemplateID']));
if (Is_Error($Template)) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
if (isset($Template['Attribs'])) {
    #-------------------------------------------------------------------------------
    foreach (Array_Keys($Template['Attribs']) as $AttribID) {
        #-------------------------------------------------------------------------------
        $Attrib = $Template['Attribs'][$AttribID];
        #-------------------------------------------------------------------------------
        switch ($Template['Attribs'][$AttribID]['Type']) {
            case 'Input':
                # No more...
            # No more...
            case 'Hidden':
Example #14
0
function WhoIs_Check($DomainName, $ZoneName, $IsAvalible = FALSE)
{
    #-------------------------------------------------------------------------------
    Debug(SPrintF('[system/libs/WhoIs]: run function WhoIs_Check, Domain = %s.%s', $DomainName, $ZoneName));
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    $CacheID = SPrintF('WhoIs-%s.%s', $DomainName, $ZoneName);
    #-------------------------------------------------------------------------------
    $Answer = CacheManager::get($CacheID);
    #-------------------------------------------------------------------------------
    if (!$Answer) {
        #-------------------------------------------------------------------------------
        # смотрим доменную зону, на предмет того использовать ли данные whois сервера, или юзать запросы к регистратору
        $DomainZones = System_XML('config/DomainZones.xml');
        if (Is_Error($DomainZones)) {
            return ERROR | @Trigger_Error('[comp/www/API/WhoIs]: не удалось загрузить базу WhoIs серверов');
        }
        #-------------------------------------------------------------------------------
        $IsSuppoted = FALSE;
        #-------------------------------------------------------------------------------
        foreach ($DomainZones as $Zone) {
            #-------------------------------------------------------------------------------
            if ($Zone['Name'] == $ZoneName) {
                #-------------------------------------------------------------------------------
                $IsSuppoted = TRUE;
                #-------------------------------------------------------------------------------
                break;
                #-------------------------------------------------------------------------------
            }
            #-------------------------------------------------------------------------------
        }
        #-------------------------------------------------------------------------------
        if (!$IsSuppoted || $Zone['IsUseRegistratorWhoIs']) {
            #-------------------------------------------------------------------------------
            if (!$IsSuppoted) {
                Debug(SPrintF('[comp/www/API/WhoIs]: доменная зона не поддерживается'));
            }
            #-------------------------------------------------------------------------------
            if ($IsSuppoted && $Zone['IsUseRegistratorWhoIs']) {
                Debug(SPrintF('[comp/www/API/WhoIs]: принудительное использование WhoIs регистратора'));
            }
            #-------------------------------------------------------------------------------
            #-------------------------------------------------------------------------------
            # чекаем доменную зону
            $Regulars = Regulars();
            #-------------------------------------------------------------------------------
            if (!Preg_Match($Regulars['DomainZone'], $ZoneName)) {
                return ERROR | @Trigger_Error(SPrintF('[comp/www/API/WhoIs]: неверная доменная зона (%s)', $ZoneName));
            }
            #-------------------------------------------------------------------------------
            # достаём список серверов на которых есть такой тариф
            $Servers = DB_Select('DomainSchemes', array('ServerID'), array('Where' => SPrintF('`Name` = "%s"', $ZoneName)));
            #-------------------------------------------------------------------------------
            switch (ValueOf($Servers)) {
                case 'error':
                    return ERROR | @Trigger_Error(500);
                case 'exception':
                    return new gException('REGISTRATOR_SERVER_NOT_FOUND', 'Не найдены активные сервера регистраторов');
                case 'array':
                    #-------------------------------------------------------------------------------
                    $Array = array();
                    #-------------------------------------------------------------------------------
                    foreach ($Servers as $Server) {
                        $Array[] = $Server['ServerID'];
                    }
                    #-------------------------------------------------------------------------------
                    break;
                    #-------------------------------------------------------------------------------
                #-------------------------------------------------------------------------------
                default:
                    return ERROR | @Trigger_Error(101);
            }
            #-------------------------------------------------------------------------------
            # достаём список активных серверов регистраторов
            $Servers = DB_Select('Servers', array('ID', 'Address', 'Params'), array('Where' => array(SPrintF('`ID` IN (%s)', Implode(',', $Array)), '`IsActive` = "yes"'), 'SortOn' => 'Address'));
            #-------------------------------------------------------------------------------
            switch (ValueOf($Servers)) {
                case 'error':
                    return ERROR | @Trigger_Error(500);
                case 'exception':
                    return new gException('REGISTRATOR_SERVER_NOT_FOUND', 'Не найдены активные сервера регистраторов');
                case 'array':
                    break;
                default:
                    return ERROR | @Trigger_Error(101);
            }
            #-------------------------------------------------------------------------------
            # перебираем регистраторов
            $UseServer = FALSE;
            #-------------------------------------------------------------------------------
            foreach ($Servers as $iServer) {
                #-------------------------------------------------------------------------------
                # если это не проверка доступности и в настройках сервера не стоит галка про получение WhoIs - пропускаем
                if (!$IsAvalible) {
                    if (!$iServer['Params']['IsFetchWhoIs']) {
                        continue;
                    }
                }
                #-------------------------------------------------------------------------------
                # достаём использованные запросы к регистратору, на данную минуту
                $RatelimitID = SPrintF('ratelimit-%s-%s-00', $iServer['Address'], Date('H-i'));
                #-------------------------------------------------------------------------------
                $Ratelimit = CacheManager::get($RatelimitID);
                #-------------------------------------------------------------------------------
                # если из кэша что-то досталось и оно больше разрешённой частоты запросов - пропускаем цикл
                if ($Ratelimit && $Ratelimit >= $iServer['Params']['RatelimitAPI']) {
                    #-------------------------------------------------------------------------------
                    Debug(SPrintF('[comp/www/API/WhoIs]: превышена частота запросов к серверу %s (разрешено %u, использовано %u)', $iServer['Address'], $iServer['Params']['RatelimitAPI'], $Ratelimit));
                    #-------------------------------------------------------------------------------
                    continue;
                    #-------------------------------------------------------------------------------
                }
                #-------------------------------------------------------------------------------
                # сохраняем, на пару минут, в кэш новое число запросов к регистратору
                CacheManager::add($RatelimitID, IntVal($Ratelimit) + 1, 120);
                #-------------------------------------------------------------------------------
                $UseServer = $iServer;
                #-------------------------------------------------------------------------------
                break;
                #-------------------------------------------------------------------------------
            }
            #-------------------------------------------------------------------------------
            # если не задан сервер - частота превышена для всех серверов
            if (!$UseServer) {
                return new gException('REGISTRATOR_SERVER_RATELIMIT', 'Превышена максимальная частота запросов к интерфейсу регистратора');
            }
            #-------------------------------------------------------------------------------
            #-------------------------------------------------------------------------------
            # выбираем сервер регистратора
            if (Is_Error(System_Load('classes/DomainServer.class.php'))) {
                return ERROR | @Trigger_Error(500);
            }
            #-------------------------------------------------------------------------------
            $Server = new DomainServer();
            #-------------------------------------------------------------------------------
            $IsSelected = $Server->Select((int) $UseServer['ID']);
            #-------------------------------------------------------------------------------
            switch (ValueOf($IsSelected)) {
                case 'error':
                    return ERROR | @Trigger_Error(500);
                case 'exception':
                    return new gException('CANNOT_SELECT_REGISTRATOR', 'Не удалось выбрать регистратора');
                case 'true':
                    break;
                default:
                    return ERROR | @Trigger_Error(101);
            }
            #-------------------------------------------------------------------------------
            # делаем запрос к API - функция в зависимости от $IsAvalible
            if ($IsAvalible) {
                #-------------------------------------------------------------------------------
                $DomainCheck = $Server->DomainCheck($DomainName, $ZoneName);
                #-------------------------------------------------------------------------------
                switch (ValueOf($DomainCheck)) {
                    case 'error':
                        return ERROR | @Trigger_Error(500);
                    case 'exception':
                        return ERROR | @Trigger_Error(400);
                    case 'true':
                        return TRUE;
                    case 'false':
                        return array();
                    case 'array':
                        break;
                    default:
                        return ERROR | @Trigger_Error(101);
                }
                #-------------------------------------------------------------------------------
            } else {
                #-------------------------------------------------------------------------------
                $DomainWhoIs = $Server->DomainWhoIs($DomainName, $ZoneName);
                #-------------------------------------------------------------------------------
                switch (ValueOf($DomainWhoIs)) {
                    case 'error':
                        return ERROR | @Trigger_Error(500);
                    case 'exception':
                        # a функции нет ... вылезаем на обычную проверку whois
                        break;
                    case 'true':
                        return TRUE;
                    case 'string':
                        #-------------------------------------------------------------------------------
                        CacheManager::add($CacheID, $DomainWhoIs, 1800);
                        #-------------------------------------------------------------------------------
                        break;
                        #-------------------------------------------------------------------------------
                    #-------------------------------------------------------------------------------
                    default:
                        return ERROR | @Trigger_Error(101);
                }
                #-------------------------------------------------------------------------------
            }
            #-------------------------------------------------------------------------------
        }
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    $Config = Config();
    #-------------------------------------------------------------------------------
    $UseSystemApplication = $Config['Other']['Libs']['WhoIs']['UseSystemApplication'];
    #-------------------------------------------------------------------------------
    $Regulars = Regulars();
    #-------------------------------------------------------------------------------
    if (!Preg_Match($Regulars['DomainName'], $DomainName)) {
        return new gException('WRONG_DOMAIN_NAME', 'Неверное доменное имя');
    }
    #-------------------------------------------------------------------------------
    $DomainZones = System_XML('config/DomainZones.xml');
    if (Is_Error($DomainZones)) {
        return ERROR | @Trigger_Error('[WhoIs_Check]: не удалось загрузить базу WhoIs серверов');
    }
    #-------------------------------------------------------------------------------
    $IsSuppoted = FALSE;
    #-------------------------------------------------------------------------------
    foreach ($DomainZones as $DomainZone) {
        #-------------------------------------------------------------------------------
        if ($DomainZone['Name'] == $ZoneName) {
            #-------------------------------------------------------------------------------
            $IsSuppoted = TRUE;
            #-------------------------------------------------------------------------------
            break;
            #-------------------------------------------------------------------------------
        }
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
    if (!$IsSuppoted && !isset($DomainWhoIs)) {
        return FALSE;
    }
    #-------------------------------------------------------------------------------
    if (Mb_StrLen($DomainName) < ($MinChars = $DomainZone['MinChars'])) {
        return new gException('WRONG_DOMAIN_NAME_LENGTH', SPrintF('Длина доменного имени должна быть не менее %u символа(ов)', $MinChars));
    }
    #-------------------------------------------------------------------------------
    $Domain = SPrintF('%s.%s', $DomainName, $DomainZone['Name']);
    #-------------------------------------------------------------------------------
    $Answer = CacheManager::get($CacheID);
    #-------------------------------------------------------------------------------
    if (!$Answer) {
        #-------------------------------------------------------------------------------
        $IDNAConverter = new IDNAConvert();
        #-------------------------------------------------------------------------------
        if ($UseSystemApplication) {
            #-------------------------------------------------------------------------------
            $IsExec = Exec(SPrintF('whois %s', $IDNAConverter->encode($Domain)), $Answer);
            #-------------------------------------------------------------------------------
            $Answer = Implode("\n", $Answer);
            #-------------------------------------------------------------------------------
        } else {
            #-------------------------------------------------------------------------------
            $Socket = @FsockOpen($DomainZone['Server'], 43, $nError, $sError, 5);
            #-------------------------------------------------------------------------------
            if (!$Socket) {
                return ERROR | @Trigger_Error('[WhoIs_Check]: ошибка соединения с сервером WhoIs');
            }
            #-------------------------------------------------------------------------------
            if (!@Fputs($Socket, SPrintF("%s\r\n", $IDNAConverter->encode($Domain)))) {
                return ERROR | @Trigger_Error('[WhoIs_Check]: ошибка работы с серверов WhoIs');
            }
            #-------------------------------------------------------------------------------
            $Answer = '';
            #-------------------------------------------------------------------------------
            do {
                #-------------------------------------------------------------------------------
                $Line = @Fgets($Socket, 10);
                #-------------------------------------------------------------------------------
                $Answer .= $Line;
                #-------------------------------------------------------------------------------
            } while ($Line);
            #-------------------------------------------------------------------------------
            Fclose($Socket);
            #-------------------------------------------------------------------------------
            CacheManager::add($CacheID, $Answer, 1800);
            #-------------------------------------------------------------------------------
        }
        #-------------------------------------------------------------------------------
        Debug(SPrintF('[system/libs/WhoIs.php]: Answer = %s', print_r($Answer, true)));
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
    if (Preg_Match(SPrintF('/%s/', $DomainZone['Available']), $Answer)) {
        return TRUE;
    }
    #-------------------------------------------------------------------------------
    if (Preg_Match(SPrintF('/%s/', $DomainZone['NotAvailable']), $Answer)) {
        return new gException('DOMAIN_NOT_AVAILABLE', 'Доменное имя не доступно для регистрации');
    }
    #-------------------------------------------------------------------------------
    $Result = array('Info' => Preg_Replace('/\\n\\s+\\n/sU', "\n", Preg_Replace('/\\%.+\\n/sU', '', $Answer)), 'ExpirationDate' => 0);
    #-------------------------------------------------------------------------------
    $ExpirationDate = $DomainZone['ExpirationDate'];
    #-------------------------------------------------------------------------------
    if ($ExpirationDate) {
        #-------------------------------------------------------------------------------
        if (Preg_Match(SPrintF('/%s/', $ExpirationDate), $Answer, $Mathes)) {
            #-------------------------------------------------------------------------------
            if (Count($Mathes) < 2) {
                return ERROR | @Trigger_Error('[WhoIs_Check]: шаблон поиска даты окончания задан неверно');
            }
            #-------------------------------------------------------------------------------
            $ExpirationDate = $Mathes[1];
            #-------------------------------------------------------------------------------
            $Months = array('jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec');
            #-------------------------------------------------------------------------------
            if (Preg_Match('/^[0-9]{4}\\.[0-9]{2}\\.[0-9]{2}$/', $ExpirationDate)) {
                #-------------------------------------------------------------------------------
                $Date = Array_Combine(array('Year', 'Month', 'Day'), Explode('.', $ExpirationDate));
                #-------------------------------------------------------------------------------
                $ExpirationDate = MkTime(0, 0, 0, $Date['Month'], $Date['Day'], $Date['Year']);
                #-------------------------------------------------------------------------------
            } elseif (Preg_Match('/^[0-9]{4}\\-[0-9]{2}\\-[0-9]{2}$/', $ExpirationDate)) {
                #-------------------------------------------------------------------------------
                $Date = Array_Combine(array('Year', 'Month', 'Day'), Explode('-', $ExpirationDate));
                #-------------------------------------------------------------------------------
                $ExpirationDate = MkTime(0, 0, 0, $Date['Month'], $Date['Day'], $Date['Year']);
                #-------------------------------------------------------------------------------
            } elseif (Preg_Match('/^[0-9]{2}\\-[a-zA-Z]{3}\\-[0-9]{4}$/', $ExpirationDate)) {
                #-------------------------------------------------------------------------------
                $Date = Array_Combine(array('Day', 'Month', 'Year'), Explode('-', $ExpirationDate));
                #-------------------------------------------------------------------------------
                $Month = Array_Search(StrToLower($Date['Month']), $Months);
                #-------------------------------------------------------------------------------
                $ExpirationDate = MkTime(0, 0, 0, $Month + 1, $Date['Day'], $Date['Year']);
                #-------------------------------------------------------------------------------
            } elseif (Preg_Match('/^[0-9]{2}\\s[a-zA-Z]{2,10}\\s[0-9]{4}$/', $ExpirationDate)) {
                #-------------------------------------------------------------------------------
                $Months = array('january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'octember', 'november', 'decemeber');
                #-------------------------------------------------------------------------------
                $Date = Array_Combine(array('Day', 'Month', 'Year'), Preg_Split('/\\s+/', $ExpirationDate));
                #-------------------------------------------------------------------------------
                $Month = Array_Search(StrToLower($Date['Month']), $Months);
                #-------------------------------------------------------------------------------
                $ExpirationDate = MkTime(0, 0, 0, $Month + 1, $Date['Day'], $Date['Year']);
                #-------------------------------------------------------------------------------
            } else {
                #-------------------------------------------------------------------------------
                $Date = Array_Combine(array('Week', 'Month', 'Day', 'Time', 'GMT', 'Year'), Preg_Split('/\\s+/', $ExpirationDate));
                #-------------------------------------------------------------------------------
                $Month = Array_Search(StrToLower($Date['Month']), $Months);
                #-------------------------------------------------------------------------------
                $ExpirationDate = MkTime(0, 0, 0, $Month + 1, $Date['Day'], $Date['Year']);
                #-------------------------------------------------------------------------------
            }
            #-------------------------------------------------------------------------------
            $Result['ExpirationDate'] = $ExpirationDate;
            #-------------------------------------------------------------------------------
        }
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
    $NsName = $DomainZone['NsName'];
    #-------------------------------------------------------------------------------
    if ($NsName) {
        #-------------------------------------------------------------------------------
        if (Preg_Match_All(SPrintF('/%s/', $NsName), $Answer, $Mathes)) {
            #-------------------------------------------------------------------------------
            if (Count($Mathes) < 2) {
                return ERROR | @Trigger_Error('[WhoIs_Check]: шаблон поиска именных серверов задан неверно');
            }
            #-------------------------------------------------------------------------------
            $NsNames = $Mathes[1];
            #-------------------------------------------------------------------------------
            for ($i = 0; $i < Count($NsNames); $i++) {
                #-------------------------------------------------------------------------------
                $NsName = Trim(StrToLower($NsNames[$i]), '.');
                #-------------------------------------------------------------------------------
                $Result[SPrintF('Ns%uName', $i + 1)] = $NsName;
                #-------------------------------------------------------------------------------
                if ($NsName) {
                    #-------------------------------------------------------------------------------
                    if (Mb_SubStr($NsName, -Mb_StrLen($Domain)) == $Domain) {
                        #-------------------------------------------------------------------------------
                        $IP = GetHostByName($NsName);
                        #-------------------------------------------------------------------------------
                        if ($IP != $NsName) {
                            $Result[SPrintF('Ns%uIP', $i + 1)] = $IP;
                        }
                        #-------------------------------------------------------------------------------
                    }
                    #-------------------------------------------------------------------------------
                }
                #-------------------------------------------------------------------------------
            }
            #-------------------------------------------------------------------------------
        }
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
    $Registrar = $DomainZone['Registrar'];
    #-------------------------------------------------------------------------------
    if ($Registrar) {
        #-------------------------------------------------------------------------------
        if (Preg_Match(SPrintF('/%s/', $Registrar), $Answer, $Mathes)) {
            #-------------------------------------------------------------------------------
            if (Count($Mathes) < 2) {
                return ERROR | @Trigger_Error('[WhoIs_Check]: шаблон поиска регистратора серверов задан неверно');
            }
            #-------------------------------------------------------------------------------
            $Registrar = Next($Mathes);
            #-------------------------------------------------------------------------------
            $Result['Registrar'] = $Registrar;
            #-------------------------------------------------------------------------------
        }
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
    return $Result;
    #-------------------------------------------------------------------------------
}
Example #15
0
 $Table[] = array('Пароль', $Comp);
 #-------------------------------------------------------------------------------
 #-------------------------------------------------------------------------------
 if ($ServerID) {
     #-------------------------------------------------------------------------------
     $Comp = Comp_Load('Form/Input', array('name' => 'ServerID', 'type' => 'hidden', 'value' => $Server['ID'], 'style' => 'width: 100%;'));
     if (Is_Error($Comp)) {
         return ERROR | @Trigger_Error(500);
     }
     #-------------------------------------------------------------------------------
     $Form->AddChild($Comp);
     #-------------------------------------------------------------------------------
 }
 #-------------------------------------------------------------------------------
 #-------------------------------------------------------------------------------
 $Template = System_XML(SPrintF('servers/%s.xml', $TemplateID));
 if (Is_Error($Template)) {
     return ERROR | @Trigger_Error(500);
 }
 #-------------------------------------------------------------------------------
 #-------------------------------------------------------------------------------
 if (isset($Template['Attribs'])) {
     #-------------------------------------------------------------------------------
     $Attribs = $Template['Attribs'];
     #-------------------------------------------------------------------------------
     #-------------------------------------------------------------------------------
     $Replace = Array_ToLine($__USER, '%');
     #-------------------------------------------------------------------------------
     foreach (Array_Keys($Attribs) as $AttribID) {
         #-------------------------------------------------------------------------------
         $Attrib = $Attribs[$AttribID];
Example #16
0
#-------------------------------------------------------------------------------
switch (ValueOf($Profiles)) {
    case 'error':
        return ERROR | @Trigger_Error(500);
    case 'exception':
        # No more...
        break;
    case 'array':
        #---------------------------------------------------------------------------
        foreach ($Profiles as $Profile) {
            #-------------------------------------------------------------------------
            $Attribs = $Profile['Attribs'];
            #-------------------------------------------------------------------------
            $TemplateID = $Profile['TemplateID'];
            #-------------------------------------------------------------------------
            $Template = System_XML(SPrintF('profiles/%s.xml', $TemplateID));
            if (Is_Error($Template)) {
                return ERROR | @Trigger_Error(500);
            }
            #-------------------------------------------------------------------------
            $Replace = Array_ToLine($Attribs, '%');
            #-------------------------------------------------------------------------
            $ProfileName = $Template['ProfileName'];
            #-------------------------------------------------------------------------
            foreach (Array_Keys($Replace) as $Key) {
                $ProfileName = Str_Replace($Key, $Replace[$Key], $ProfileName);
            }
            #-------------------------------------------------------------------------
            $IsUpdate = DB_Update('Profiles', array('Name' => $ProfileName), array('ID' => $Profile['ID']));
            if (Is_Error($IsUpdate)) {
                return ERROR | @Trigger_Error(500);
Example #17
0
$XML = String_XML_Parse($Response['Body']);
if (Is_Exception($XML)) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
$XML = $XML->ToArray('Valute');
#-------------------------------------------------------------------------------
$Courses = (array) $XML['ValCurs'];
#-------------------------------------------------------------------------------
$Config = Config();
#-------------------------------------------------------------------------------
$cPaymentSystems = $Config['Invoices']['PaymentSystems'];
#-------------------------------------------------------------------------------
$HostsIDs = $GLOBALS['HOST_CONF']['HostsIDs'];
#-------------------------------------------------------------------------------
$Config = System_XML('config/Config.xml', Current($HostsIDs));
if (Is_Error($Config)) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
if (!isset($Config['Invoices'])) {
    $Config['Invoices'] = array();
}
#-------------------------------------------------------------------------------
$Invoices =& $Config['Invoices'];
#-------------------------------------------------------------------------------
if (!isset($Invoices['PaymentSystems'])) {
    $Invoices['PaymentSystems'] = array();
}
#-------------------------------------------------------------------------------
$PaymentSystems =& $Invoices['PaymentSystems'];
        }
        #-------------------------------------------------------------------------------
        $Params = Array_ToLine($Config);
        #-------------------------------------------------------------------------------
        foreach (Array_Keys($Params) as $Key) {
            if (!In_Array($Key, $ShareConfigsParams)) {
                $ShareConfigsParams[] = $Key;
            }
        }
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$Config = System_XML('config/Config.xml', array(HOST_ID));
if (Is_Error($Config)) {
    return new gException('ERROR_TEMPLATE_LOAD', 'Ошибка загрузки шаблона');
}
#-------------------------------------------------------------------------------
$Params = Array_ToLine($Config);
#-------------------------------------------------------------------------------
foreach (Array_Keys($Params) as $Key) {
    #-------------------------------------------------------------------------------
    if (!In_Array($Key, $ShareConfigsParams)) {
        #-------------------------------------------------------------------------------
        Debug(SPrintF('[comp/Tasks/GC/CheckConfigParams]: в конфигурационном файле обнаружен не используемый параметр: %s', $Key));
        #-------------------------------------------------------------------------------
        if ($Settings['IsEvent']) {
            #-------------------------------------------------------------------------------
            $Event = array('IsReaded' => FALSE, 'PriorityID' => 'System', 'Text' => SPrintF('Обнаружен неиспользуемый параметр конфигурационного файла: %s, со значением (%s). Удалите его, или отключите задачу поиска неиспользуемых параметров. При удалении, будте аккуратны и внимательны, сохраняйте бэкап конфигурационного файла.', $Key, $Params[$Key]));
Example #19
0
<?php

#-------------------------------------------------------------------------------
/** @author Великодный В.В. (Joonte Ltd.) */
#-------------------------------------------------------------------------------
$Codes = System_XML('tmp/protect.xml');
if (Is_Error($Codes)) {
    $Codes = array();
}
#-------------------------------------------------------------------------------
foreach (Array_Keys($Codes) as $CodeID) {
    #-----------------------------------------------------------------------------
    if (Time() - $Codes[$CodeID]['Date'] > 300) {
        unset($Codes[$CodeID]);
    }
}
#-------------------------------------------------------------------------------
$IsExists = FALSE;
#-------------------------------------------------------------------------------
foreach (Array_Keys($Codes) as $CodeID) {
    #-----------------------------------------------------------------------------
    $Code = $Codes[$CodeID];
    #-----------------------------------------------------------------------------
    if ($Code['IP'] == $_SERVER['REMOTE_ADDR']) {
        #---------------------------------------------------------------------------
        $IsExists = TRUE;
        #---------------------------------------------------------------------------
        $Secret = $Code['Secret'];
        #---------------------------------------------------------------------------
        break;
    }