Esempio n. 1
0
function GetTime($Data)
{
    #-------------------------------------------------------------------------------
    if (Preg_Match('/^[0-9]+$/', $Data)) {
        return $Data;
    }
    #-------------------------------------------------------------------------------
    $Date = @Date_Parse($Data);
    #-------------------------------------------------------------------------------
    if (!Is_Array($Date)) {
        return ERROR | @Trigger_Error('[GetTime]: ошибка получения даты');
    }
    #-------------------------------------------------------------------------------
    return MkTime($Date['hour'], $Date['minute'], $Date['second'], $Date['month'], $Date['day'], $Date['year']);
    #-------------------------------------------------------------------------------
}
Esempio n. 2
0
function Cache_Delete($Pattern)
{
    #-----------------------------------------------------------------------------
    $Cache =& Link_Get('Cache', 'array');
    #-----------------------------------------------------------------------------
    foreach (Array_Keys($Cache) as $Key) {
        #---------------------------------------------------------------------------
        if (Preg_Match(SPrintF('/%s/', $Pattern), $Key)) {
            #-------------------------------------------------------------------------
            # Debug(SPrintF('[Cache_Delete]: удаление объекта из кеша (%s)',$Key));
            #-------------------------------------------------------------------------
            unset($Cache[$Key]);
        }
    }
    #-----------------------------------------------------------------------------
    return TRUE;
}
Esempio n. 3
0
function CleanUpElem(&$elem_name, &$cfg_file, &$template)
{
    // Fixes HEX strings to look like 0xABCDEF12345 rather than 0Xabc or 0xaf
    if (Preg_Match("/(0x)([a-fA-F0-9]+)/i", $elem_name, $matches)) {
        $elem_name = Preg_Replace("/(0x)([a-fA-F0-9]+)/i", "0x" . StrToUpper($matches[2]), $elem_name);
    }
    print "    Cleaning up elem '{$elem_name}'\n";
    $cfg_elem = FindConfigElem($cfg_file, $elem_name);
    $cfg_elem = array_change_key_case($cfg_elem, CASE_LOWER);
    $new_elem = array();
    $last_label = 0;
    foreach ($template as $indice => $line) {
        if (Preg_Match('/\\[Label=([[:alnum:][:space:][:punct:]]+)\\]/', $line, $matches)) {
            if ($last_label) {
                unset($new_elem[$last_label]);
            }
            $matches[1] = Preg_Replace("/%s/i", " ", $matches[1]);
            $line = "//{$matches[1]}";
            if ($indice > 1) {
                $line = "\n\t{$line}";
            }
            $last_label = $line;
            $new_elem[$line] = array("");
            continue;
        } else {
            $property = StrToLower($line);
            if ($cfg_elem[$property]) {
                $new_elem[$line] = $cfg_elem[$property];
                unset($cfg_elem[$property]);
                $last_label = 0;
            }
        }
    }
    if (Count($cfg_elem) > 0) {
        $new_elem["\n\t//Custom Values"] = array("");
        // Lines not in the template go at the end as custom values
        foreach ($cfg_elem as $key => $value) {
            $new_elem[$key] = $value;
        }
    }
    if ($last_label) {
        unset($new_elem[$last_label]);
    }
    return $new_elem;
}
Esempio n. 4
0
function TemplateReplace($Text, $Params = array(), $NoBody = TRUE)
{
    #-------------------------------------------------------------------------------
    $Text = Trim($Text);
    #-------------------------------------------------------------------------------
    # проверяем что нам сунули - текст или файл
    if (!Preg_Match('/\\s/', $Text)) {
        #-------------------------------------------------------------------------------
        # достаём текст из файла
        $Path = System_Element(SPrintF('templates/modules/%s.html', $Text));
        #-------------------------------------------------------------------------------
        if (Is_Error($Path)) {
            #-------------------------------------------------------------------------------
            $Text = SprintF('Отсутствует шаблон сообщения (templates/modules/%s.html)', $Text);
            #-------------------------------------------------------------------------------
        } else {
            #-------------------------------------------------------------------------------
            $Text = Trim(IO_Read($Path));
            #-------------------------------------------------------------------------------
        }
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    if ($NoBody) {
        $Text = SPrintF('<NOBODY><SPAN>%s</SPAN></NOBODY>', $Text);
    }
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    $Replace = Array_ToLine($Params, '%');
    #-------------------------------------------------------------------------------
    foreach (Array_Keys($Replace) as $Key) {
        $Text = Str_Replace($Key, $Replace[$Key], $Text);
    }
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    return $Text;
    #-------------------------------------------------------------------------------
}
Esempio n. 5
0
function BuildItemDesc($file)
{
    print " * Loading multis config file...\n";
    $cfg_file = ReadConfigFile($file);
    if ($cfg_file == FALSE) {
        print "Cant open {$file} ({$php_errormsg}). Blame Stephen Donald.\n";
        exit;
    }
    print " * Purging itemdesc.cfg for new write...\n";
    $handle = FOpen("itemdesc.cfg", "w");
    FClose($handle);
    $handle = FOpen("itemdesc.cfg", "a");
    print " * Finding elem names...";
    $elem_names = GetConfigStringKeys($cfg_file, CLASS_LABELS_ON);
    print "(" . Count($elem_names) . ")\n";
    foreach ($elem_names as $elem_name) {
        if (!Preg_Match("/^House\\s+/i", $elem_name)) {
            continue;
        }
        $multi_id = Preg_Replace("/^House\\s+/i", "", $elem_name);
        $objtype = HexDec($multi_id);
        $objtype += 16384;
        // 0x4000
        $objtype = "0x" . DecHex($objtype);
        FWrite($handle, "House {$objtype}\n");
        FWrite($handle, "{\n");
        FWrite($handle, "\t// Main Stuff\n");
        FWrite($handle, "\tName\t\tHouse{$objtype}\n");
        FWrite($handle, "\tGraphic\t\t{$objtype}\n");
        FWrite($handle, "\n");
        FWrite($handle, "\t// Multi Info\n");
        FWrite($handle, "\tMultiID\t\t{$multi_id}\n");
        FWrite($handle, "}\n\n");
    }
    FClose($handle);
    return 1;
}
Esempio n. 6
0
function Cpanel_Password_Change($Settings, $Login, $Password, $Params)
{
    /****************************************************************************/
    $__args_types = array('array', 'string', 'string', 'array');
    #-----------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /****************************************************************************/
    $HTTP = array('Address' => $Settings['Params']['IP'], 'Port' => $Settings['Port'], 'Host' => $Settings['Address'], 'Protocol' => $Settings['Protocol'], 'Basic' => SPrintF('%s:%s', $Settings['Login'], $Settings['Password']), 'IsLogging' => $Settings['Params']['IsLogging']);
    #-----------------------------------------------------------------------------
    $Request = array('user' => $Login, 'pass' => $Password);
    #-----------------------------------------------------------------------------
    $Response = HTTP_Send('/xml-api/passwd', $HTTP, $Request);
    if (Is_Error($Response)) {
        return ERROR | @Trigger_Error('[Cpanel_Password_Change]: не удалось осуществить запрос');
    }
    #-----------------------------------------------------------------------------
    $Response = Trim($Response['Body']);
    #-----------------------------------------------------------------------------
    if (Preg_Match('/Password\\schanged/', $Response)) {
        return TRUE;
    }
    #-----------------------------------------------------------------------------
    return new gException('WRONG_ANSWER', $Response);
}
Esempio n. 7
0
     # No more...
 # No more...
 case 'Hidden':
     # No more...
 # No more...
 case 'TextArea':
     #-------------------------------------------------------------------------------
     if ($Value) {
         #-------------------------------------------------------------------------------
         $Check = $Attrib['Check'];
         #-------------------------------------------------------------------------------
         if (isset($Regulars[$Check])) {
             $Check = $Regulars[$Check];
         }
         #-------------------------------------------------------------------------------
         if (!Preg_Match($Check, $Value)) {
             #-------------------------------------------------------------------------------
             $Errors[] = $AttribID;
             #-------------------------------------------------------------------------------
             Debug(SPrintF('[comp/www/Administrator/API/ServerEdit]: Check = %s; Value = %s', $Check, $Value));
             #-------------------------------------------------------------------------------
         }
         #-------------------------------------------------------------------------------
     } else {
         #-------------------------------------------------------------------------------
         if ($Attrib['IsDuty']) {
             $Errors[] = $AttribID;
         }
         #-------------------------------------------------------------------------------
     }
     #-------------------------------------------------------------------------------
Esempio n. 8
0
 /**
 * Удаляет объект из списка объектов
 *
 * Функция удаляет объект из массива ссылок на объкты по идентификатору $LinkID.
 *
 * @param string <идентификатор ссылки>
 */
 public function Delete($LinkID)
 {
     #-----------------------------------------------------------------------------
     $Names = Func_Get_Args();
     #-----------------------------------------------------------------------------
     foreach (Array_Keys($this->Links) as $LinkID) {
         #---------------------------------------------------------------------------
         foreach ($Names as $Name) {
             #-------------------------------------------------------------------------
             if (Preg_Match(SPrintF('/^%s(#[a-zA-Z0-9]+){0,1}$/', $Name), $LinkID)) {
                 #-----------------------------------------------------------------------
                 # Debug(SPrintF('[DOM->Delete]: удаление объектов по ссылке (%s -> %s)',$Name,$LinkID));
                 #-----------------------------------------------------------------------
                 $this->Links[$LinkID] = NULL;
             }
         }
     }
     #-----------------------------------------------------------------------------
     $this->Linking();
 }
Esempio n. 9
0
 foreach ($HostsIDs as $HostID) {
     #-------------------------------------------------------------------------------
     $Path = SPrintF('%s/%s/%s', SYSTEM_PATH, $Folder, $HostID);
     #-------------------------------------------------------------------------------
     if (!File_Exists($Path)) {
         continue;
     }
     #-------------------------------------------------------------------------------
     $Files = IO_Files($Path);
     if (Is_Error($Files)) {
         return SPrintF("---\n%s\n---\n", Implode("\n", Array_Slice($__SYSLOG, Count($__SYSLOG) - 20)));
     }
     #-------------------------------------------------------------------------------
     foreach ($Files as $File) {
         #-------------------------------------------------------------------------------
         if (Preg_Match('/(tmp|LastPatchFiles)/', $File)) {
             continue;
         }
         #-------------------------------------------------------------------------------
         $MD5 = MD5_File($File);
         if (!$MD5) {
             return SPrintF("---\n%s\n---\n", Implode("\n", Array_Slice($__SYSLOG, Count($__SYSLOG) - 20)));
         }
         #-------------------------------------------------------------------------------
         $File = SubStr($File, StrLen(SYSTEM_PATH) + 1);
         #-------------------------------------------------------------------------------
         $Snapshot[SPrintF('MD5%s', MD5(SPrintF('%s-%s', $MD5, MD5($File))))] = $File;
         #-------------------------------------------------------------------------------
     }
     #-------------------------------------------------------------------------------
 }
Esempio n. 10
0
         # prepare for java script
         $Text = Str_Replace("\n", '\\n', $Text);
         # format: SortOrder:ImageName.gif
         # button image, get image name
         $Partition = Explode(":", $Article['Partition']);
         $Extension = isset($Partition[1]) ? Explode(".", StrToLower($Partition[1])) : '';
         #-------------------------------------------------------------------------------
         # если есть чё-то после точки, и если оно похоже на расширение картинки, ставим это как картинку
         $Image = 'Info.gif';
         #дефолтовую информационную картинку
         if (isset($Extension[1]) && In_Array($Extension[1], array('png', 'gif', 'jpg', 'jpeg'))) {
             $Image = $Partition[1];
         }
         #-------------------------------------------------------------------------------
         # делаем кнопку, если это системная кнопка или этого админа
         if (!Preg_Match('/@/', $Partition[0]) && $Partition[0] < 2000 && $__USER['Params']['Settings']['EdeskButtons'] == "No" || StrToLower($Partition[0]) == StrToLower($__USER['Email'])) {
             #-------------------------------------------------------------------------------
             $Comp = Comp_Load('Buttons/Standard', array('onclick' => SPrintF("form.Message.value += '%s';form.Message.focus();", $Text), 'style' => 'cursor: pointer;'), $Article['Title'], $Image);
             if (Is_Error($Comp)) {
                 return ERROR | @Trigger_Error(500);
             }
             #-------------------------------------------------------------------------------
             $Tr->AddChild(new Tag('TD', $Comp));
             #-------------------------------------------------------------------------------
         }
         #-------------------------------------------------------------------------------
     }
     #-------------------------------------------------------------------------------
     break;
     #-------------------------------------------------------------------------------
 #-------------------------------------------------------------------------------
Esempio n. 11
0
if (!$Count) {
    return new gException('GROUP_NOT_FOUND', 'Группа не найдена');
}
#-------------------------------------------------------------------------------
$Count = DB_Count('Users', array('ID' => $UserID));
if (Is_Error($Count)) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
if (!$Count) {
    return new gException('USER_NOT_FOUND', 'Пользователь не найден');
}
#-------------------------------------------------------------------------------
$Regulars = Regulars();
#-------------------------------------------------------------------------------
if (!Preg_Match('/^[A-Za-zА-ЯёЁа-я0-9\\s\\.\\-]+$/u', $Name)) {
    return new gException('WRONG_SCHEME_NAME', 'Неверное имя тарифа');
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$Count = DB_Count('ServersGroups', array('ID' => $ServersGroupID));
if (Is_Error($Count)) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
if (!$Count) {
    return new gException('SERVERS_GROUP_NOT_FOUND', 'Группа серверов не найдена');
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
if ($HardServerID > 0) {
Esempio n. 12
0
/******************************************************************************/
eval(COMP_INIT);
/******************************************************************************/
/******************************************************************************/
$Args = Args();
#-------------------------------------------------------------------------------
$ModeID = (string) @$Args['ModeID'];
$RowID = (int) @$Args['RowID'];
#-------------------------------------------------------------------------------
if (Is_Error(System_Load('modules/Authorisation.mod', 'classes/DOM.class.php'))) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
$Regulars = Regulars();
#-------------------------------------------------------------------------------
if (!Preg_Match($Regulars['ID'], $ModeID)) {
    return ERROR | @Trigger_Error(201);
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$Config = Config();
#-------------------------------------------------------------------------------
$Statuses = $Config['Statuses'][$ModeID];
#-------------------------------------------------------------------------------
$Row = DB_Select(SPrintF('%sOwners', $ModeID), 'UserID', array('UNIQ', 'Limits' => array(0, 1), 'Where' => SPrintF("`ID` = %u", $RowID)));
#-------------------------------------------------------------------------------
switch (ValueOf($Row)) {
    case 'error':
        return ERROR | @Trigger_Error(500);
    case 'exception':
        return ERROR | @Trigger_Error(400);
Esempio n. 13
0
function RuCenter_Contract_Register($Settings, $PepsonID, $Person, $DomainZone)
{
    /****************************************************************************/
    $__args_types = array('array', 'string', 'array', 'string');
    #-----------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /****************************************************************************/
    $HTTP = array('Address' => $Settings['Address'], 'Port' => $Settings['Port'], 'Host' => $Settings['Address'], 'Protocol' => $Settings['Protocol'], 'Charset' => 'KOI8-R', 'IsLogging' => $Settings['Params']['IsLogging']);
    #-----------------------------------------------------------------------------
    $Query = array();
    #---------------------------------------------------------------------------
    $RequestID = UniqID('ID');
    #---------------------------------------------------------------------------
    $Query[] = 'lang: ru';
    $Query[] = 'request: contract';
    $Query[] = 'operation: create';
    $Query[] = SPrintF('login: %s', $Settings['Login']);
    $Query[] = SPrintF('password: %s', $Settings['Password']);
    $Query[] = SPrintF('request-id: %s', $RequestID);
    #---------------------------------------------------------------------------
    $Query[] = '';
    #---------------------------------------------------------------------------
    $Query[] = '[contract]';
    $Query[] = SPrintF('password: %s', UniqID());
    $Query[] = SPrintF('tech-password: %s', UniqID());
    $Query[] = 'currency-id: RUR';
    #---------------------------------------------------------------------------
    $Query[] = '';
    #---------------------------------------------------------------------------
    switch ($PepsonID) {
        case 'Natural':
            #-----------------------------------------------------------------------
            $Query[] = 'contract-type: PRS';
            $Query[] = SPrintF('person: %s %s %s', Translit($Person['Name']), Mb_SubStr(Translit($Person['Lastname']), 0, 1), Translit($Person['Sourname']));
            $Query[] = SPrintF('person-r: %s %s %s', $Person['Sourname'], $Person['Name'], $Person['Lastname']);
            $Query[] = SPrintF('country: %s', isset($Person['PasportCountry']) ? $Person['PasportCountry'] : $Person['pCountry']);
            $Query[] = SPrintF('phone: %s', $Person['Phone']);
            $Query[] = SPrintF('fax-no: %s', $Person['Fax']);
            $Query[] = SPrintF('birth-date: %s', $Person['BornDate']);
            $Query[] = SPrintF('passport: %s %s выдан %s, %s', $Person['PasportLine'], $Person['PasportNum'], $Person['PasportWhom'], $Person['PasportDate']);
            $Query[] = SPrintF('p-addr: %s, %s, %s, %s %s, %s', $Person['pIndex'], $Person['pState'], $Person['pCity'], $Person['pType'], $Person['pAddress'], $Person['pRecipient']);
            $Query[] = SPrintF('e-mail: %s', $Person['Email']);
            break;
        case 'Juridical':
            #-----------------------------------------------------------------------
            $Query[] = 'client-type: ORG';
            $Query[] = SPrintF('org: %s %s', Translit($Person['CompanyName']), Translit($Person['CompanyFormFull']));
            $Query[] = SPrintF('org-r: %s', SPrintF('%s "%s"', $Person['CompanyFormFull'], $Person['CompanyName']));
            $Query[] = SPrintF('country: %s', $Person['jCountry']);
            $Query[] = SPrintF('e-mail: %s', $Person['Email']);
            $Query[] = SPrintF('phone: %s', $Person['Phone']);
            $Query[] = SPrintF('fax-no: %s', $Person['Fax']);
            $Query[] = SPrintF('code: %s', $Person['Inn']);
            $Query[] = SPrintF('kpp: %s', $Person['Kpp']);
            $Query[] = SPrintF('address-r: %s, %s, %s, %s %s', $Person['jIndex'], $Person['jState'], $Person['jCity'], $Person['jType'], $Person['jAddress']);
            $Query[] = SPrintF('p-addr: %s, %s, %s, %s %s, %s "%s"', $Person['pIndex'], $Person['pState'], $Person['pCity'], $Person['pType'], $Person['pAddress'], $Person['CompanyFormFull'], $Person['CompanyName']);
            $Query[] = SPrintF('d-addr: %s, %s, %s, %s %s', $Person['jIndex'], $Person['jState'], $Person['jCity'], $Person['jType'], $Person['jAddress']);
            break;
        default:
            return new gException('WRONG_PROFILE_ID', 'Неверный идентификатор профиля');
    }
    #-----------------------------------------------------------------------------
    $Result = HTTP_Send('/dns/dealer', $HTTP, array(), array('SimpleRequest' => Implode("\n", $Query)));
    if (Is_Error($Result)) {
        return ERROR | @Trigger_Error('[RuCenter_Contract_Register]: не удалось выполнить запрос к серверу');
    }
    #-----------------------------------------------------------------------------
    if (Preg_Match('/HTTP\\/1.0\\s502/i', $Result['Heads'])) {
        return false;
    }
    #-----------------------------------------------------------------------------
    $Result = Trim($Result['Body']);
    #-----------------------------------------------------------------------------
    if (Preg_Match('/State:\\s([0-9]+)/', $Result, $CodeID)) {
        #---------------------------------------------------------------------------
        $CodeID = Next($CodeID);
        #---------------------------------------------------------------------------
        switch ($CodeID) {
            case '200':
                #-----------------------------------------------------------------------
                if (!Preg_Match('/nic-hdl:\\s([0-9]+\\/[A-Z\\-]+)/', $Result, $ContractID)) {
                    return new gException('LOGIN_NOT_FOUND', 'Неудалось получить номер договора');
                } else {
                    $ContractID = Next($ContractID);
                }
                break;
            case '500':
                return FALSE;
            default:
                return new gException('WRONG_ERROR', SPrintF('Неизвестный статус ошибки (%s)', $Result));
        }
    } else {
        return new gException('WRONG_ANSWER', $Result);
    }
    #-----------------------------------------------------------------------------
    # Делаем паузу перед запросом
    Sleep(10);
    #-----------------------------------------------------------------------------
    if (!In_Array($DomainZone, array('ru', 'su'))) {
        #---------------------------------------------------------------------------
        $Query = array();
        #---------------------------------------------------------------------------
        $RequestID = UniqID('ID');
        #---------------------------------------------------------------------------
        $Query[] = SPrintF('login: %s', $Settings['Login']);
        $Query[] = SPrintF('password: %s', $Settings['Password']);
        $Query[] = SPrintF('subject-contract: %s', $ContractID);
        $Query[] = 'request: contact';
        $Query[] = 'operation: create';
        $Query[] = 'lang: ru';
        $Query[] = SPrintF('request-id: %s', $RequestID);
        #---------------------------------------------------------------------------
        $Query[] = '';
        #---------------------------------------------------------------------------
        $Query[] = '[contact]';
        $Query[] = SPrintF('status:registrant');
        $Query[] = SPrintF('org:');
        $Query[] = SPrintF('name: %s, %s', Translit($Person['Name']), Translit($Person['Lastname']));
        $Query[] = SPrintF('country: %s', isset($Person['PasportCountry']) ? $Person['PasportCountry'] : $Person['pCountry']);
        $Query[] = SPrintF('region: %s', Translit($Person['pCity']));
        $Query[] = SPrintF('city: %s', Translit($Person['pCity']));
        $Query[] = SPrintF('street: %s', Translit(SPrintF('%s %s', $Person['pType'], $Person['pAddress'])));
        $Query[] = SPrintF('zipcode: %s', $Person['pIndex']);
        $Query[] = SPrintF('phone: %s', $Person['Phone']);
        $Query[] = SPrintF('fax: %s', $Person['Fax']);
        $Query[] = SPrintF('email: %s', $Person['Email']);
        #---------------------------------------------------------------------------
        $Result = HTTP_Send('/dns/dealer', $HTTP, array(), array('SimpleRequest' => Implode("\n", $Query)));
        if (Is_Error($Result)) {
            return ERROR | @Trigger_Error('[RuCenter_Contract_Register]: не удалось выполнить запрос к серверу');
        }
        #---------------------------------------------------------------------------
        if (Preg_Match('/HTTP\\/1.0\\s502/i', $Result['Heads'])) {
            return FALSE;
        }
        #---------------------------------------------------------------------------
        $Result = Trim($Result['Body']);
        #---------------------------------------------------------------------------
        if (Preg_Match('/State:\\s([0-9]+)/', $Result, $CodeID)) {
            #-------------------------------------------------------------------------
            $CodeID = Next($CodeID);
            #-------------------------------------------------------------------------
            switch ($CodeID) {
                case '200':
                    #-----------------------------------------------------------------------
                    if (!Preg_Match('/nic-hdl:([0-9A-Za-z\\-]+)/', $Result, $NicHDL)) {
                        return array('TicketID' => SPrintF('%s:%s', $ContractID, Next($NicHDL)));
                    }
                    #-----------------------------------------------------------------------
                    return new gException('LOGIN_NOT_FOUND', 'Неудалось получить номер договора');
                case '500':
                    return FALSE;
                default:
                    return new gException('WRONG_ERROR', SPrintF('Неизвестный статус ошибки (%s)', $Result));
            }
        } else {
            return new gException('WRONG_ANSWER', $Result);
        }
    }
    #-----------------------------------------------------------------------------
    return array('TicketID' => $ContractID);
}
 public function getParams()
 {
     #-------------------------------------------------------------------------------
     # Достаем registrar и его префикс
     if (Preg_Match('/registrar:\\s+((\\w+|-)+)/', $this->params['WhoIs'], $String)) {
         #-------------------------------------------------------------------------------
         $Registrar = Next($String);
         #-------------------------------------------------------------------------------
         if (Preg_Match('/((\\w+|-)+)-(REG|RU)/', $Registrar, $String)) {
             $PrefixRegistrar = Next($String);
         }
         #-------------------------------------------------------------------------------
     }
     #-------------------------------------------------------------------------------
     #-------------------------------------------------------------------------------
     # Получаем параметры для формирования Event
     $Where = SPrintF('`OrderID` = %s', $this->params['OrderID']);
     $UserID = DB_Select('DomainOrdersOwners', 'UserID as ID', array('UNIQ', 'Where' => $Where));
     $SchemeName = DB_Select('DomainSchemes', 'Name as SchemeName', array('UNIQ', 'ID' => $this->params['SchemeID']));
     #-------------------------------------------------------------------------------
     #-------------------------------------------------------------------------------
     if (In_Array($SchemeName['SchemeName'], array('ru', 'su', 'рф'))) {
         #-------------------------------------------------------------------------------
         if (isset($Registrar) && isset($PrefixRegistrar)) {
             #-------------------------------------------------------------------------------
             $this->params['registrar'] = $Registrar;
             $this->params['prefixRegistrar'] = $PrefixRegistrar;
             #-------------------------------------------------------------------------------
             # Получаем параметры регистратора к которому осуществляется трансфер
             $ServerID = DB_Select('DomainSchemes', '`ServerID` AS `ID`', array('UNIQ', 'ID' => $this->params['SchemeID']));
             $Settings = DB_Select('Servers', '*', array('UNIQ', 'ID' => $ServerID['ID']));
             #-------------------------------------------------------------------------------
             Debug("[system/classes/DomainOrdersForTransferMsg.class.php]: Servers[SystemID] - " . $Settings['Params']['SystemID']);
             Debug("[system/classes/DomainOrdersForTransferMsg.class.php]: Settings[PrefixNic] - " . $Settings['Params']['PrefixNic']);
             Debug("[system/classes/DomainOrdersForTransferMsg.class.php]: Registrar - " . $Registrar);
             Debug("[system/classes/DomainOrdersForTransferMsg.class.php]: PrefixRegistrar - " . $PrefixRegistrar);
             #-------------------------------------------------------------------------------
             # Проверяем является ли регистрар нашим регистратором
             if ($PrefixRegistrar == $Settings['Params']['PrefixNic']) {
                 #-------------------------------------------------------------------------------
                 $this->params['internalRegister'] = true;
                 #---------------------------------------------------------------------------
                 Debug("[system/classes/DomainOrdersForTransferMsg.class.php]: IsOurRegistrar - TRUE");
                 Debug("[system/classes/DomainOrdersForTransferMsg.class.php]: Инструкция по трансферу в пределах регистратора");
                 #---------------------------------------------------------------------------
                 $this->params['registratorID'] = $Settings['Params']['SystemID'];
                 $this->params['partnerLogin'] = $Settings['Params']['PartnerLogin'];
                 $this->params['partnerContract'] = $Settings['Params']['PartnerContract'];
                 #-------------------------------------------------------------------------------
                 # Достаем статью с информацией о шаблонах документов и контактами регистратора
                 $Where = SPrintF('`Partition` = "Registrators/%s/internal"', $PrefixRegistrar);
                 $Clause = DB_Select('Clauses', '*', array('UNIQ', 'Where' => $Where));
                 switch (ValueOf($Clause)) {
                     case 'array':
                         #-------------------------------------------------------------------------------
                         $TransferDoc = trim(Strip_Tags($Clause['Text']));
                         break;
                         #-------------------------------------------------------------------------------
                     #-------------------------------------------------------------------------------
                     default:
                         #-------------------------------------------------------------------------------
                         Debug(SPrintF('[system/classes/DomainOrdersForTransferMsg.class.php]: Статья не найдена. Ожидалась Registrators/%s/internal', $PrefixRegistrar));
                         #-------------------------------------------------------------------------------
                         $TransferDoc = "Для получения информации об оформлении писем Вашему текущему регистратору и его контактах перейдите на его сайт.";
                         #-------------------------------------------------------------------------------
                         # Уведомление об ошибке статьи
                         $Event = array('UserID' => $UserID['ID'], 'PriorityID' => 'Error', 'Text' => SPrintF('Статья по переносу домена не найдена. Ожидалась Registrators/%s/internal', $PrefixRegistrar), 'IsReaded' => FALSE);
                         #-------------------------------------------------------------------------------
                         $Event = Comp_Load('Events/EventInsert', $Event);
                         if (!$Event) {
                             return ERROR | @Trigger_Error(500);
                         }
                         #-------------------------------------------------------------------------------
                 }
                 #-------------------------------------------------------------------------------
                 $this->params['transferDoc'] = $TransferDoc;
                 #-------------------------------------------------------------------------------
             } else {
                 #-------------------------------------------------------------------------------
                 $this->params['internalRegister'] = false;
                 #-------------------------------------------------------------------------------
                 Debug("[system/classes/DomainOrdersForTransferMsg.class.php]: Инструкция по трансферу от стороннего регистратора");
                 #-------------------------------------------------------------------------------
                 # Формируем постфикс идентификатора
                 switch ($SchemeName['SchemeName']) {
                     case 'su':
                         $PostfixNic = 'FID';
                         break;
                     case 'рф':
                         $PostfixNic = 'RF';
                         break;
                     default:
                         $PostfixNic = 'RU';
                 }
                 #-------------------------------------------------------------------------------
                 $this->params['registrar'] = $Registrar;
                 $this->params['registratorID'] = $Settings['Params']['SystemID'];
                 $this->params['jurName'] = $Settings['Params']['JurName'];
                 $this->params['prefixNic'] = $Settings['Params']['PrefixNic'];
                 $this->params['postfixNic'] = $PostfixNic;
                 $this->params['schemeName'] = StrToUpper($SchemeName['SchemeName']);
                 #-------------------------------------------------------------------------------
                 # Достаем статью с информацией о шаблонах документов и контактами регистратора
                 $Where = SPrintF('`Partition` = "Registrators/%s/external"', $PrefixRegistrar);
                 $Clause = DB_Select('Clauses', '*', array('UNIQ', 'Where' => $Where));
                 switch (ValueOf($Clause)) {
                     case 'array':
                         $TransferDoc = trim(Strip_Tags($Clause['Text']));
                         break;
                     default:
                         #-------------------------------------------------------------------------------
                         Debug(SPrintF('[system/classes/DomainOrdersForTransferMsg.class.php]: Статья не найдена. Ожидалась Registrators/%s/external', $PrefixRegistrar));
                         #-------------------------------------------------------------------------------
                         $TransferDoc = "\n\nДля получения информации об оформлении писем Вашему текущему регистратору и его контактах перейдите на его сайт.";
                         #-------------------------------------------------------------------------------
                         # Уведомление об ошибке статьи
                         $Event = array('UserID' => $UserID['ID'], 'PriorityID' => 'Error', 'Text' => SPrintF('Статья по переносу домена не найдена. Ожидалась Registrators/%s/external', $PrefixRegistrar), 'IsReaded' => FALSE);
                         $Event = Comp_Load('Events/EventInsert', $Event);
                         if (!$Event) {
                             return ERROR | @Trigger_Error(500);
                         }
                         #-------------------------------------------------------------------------------
                 }
                 #-------------------------------------------------------------------------------
                 $this->params['transferDoc'] = $TransferDoc;
                 #-------------------------------------------------------------------------------
             }
             #-------------------------------------------------------------------------------
         } else {
             #-------------------------------------------------------------------------------
             Debug("[system/classes/DomainOrdersForTransferMsg.class.php]: Registrar или PrefixRegistrar не был определён.");
             # Уведомление об ошибке формирования инструкции
             $Event = array('UserID' => $UserID['ID'], 'PriorityID' => 'Error', 'Text' => SPrintF('Ошибка автоматического формирования инструкции по переносу домена (%s.%s) к нам.', $this->params['DomainName'], $SchemeName['SchemeName']), 'IsReaded' => FALSE);
             $Event = Comp_Load('Events/EventInsert', $Event);
             if (!$Event) {
                 return ERROR | @Trigger_Error(500);
             }
             #-------------------------------------------------------------------------------
         }
         #-------------------------------------------------------------------------------
     } else {
         #-------------------------------------------------------------------------------
         // буржуйские домены, пеерносятся через AuthInfo
         $this->params['notUSSR'] = TRUE;
         $this->params['schemeName'] = StrToUpper($SchemeName['SchemeName']);
         #-------------------------------------------------------------------------------
     }
     #-------------------------------------------------------------------------------
     return $this->params;
     #-------------------------------------------------------------------------------
 }
Esempio n. 15
0
             continue 2;
         }
         #-------------------------------------------------------------------------------
         break;
         #-------------------------------------------------------------------------------
     #-------------------------------------------------------------------------------
     default:
         return ERROR | @Trigger_Error(101);
 }
 #-------------------------------------------------------------------------------
 #-------------------------------------------------------------------------------
 # проверяем, есть ли такие услуги у юзера
 $Code = isset($Type['Code']) ? $Type['Code'] : $Code;
 $Regulars = SPrintF('/^%s/', $Code);
 #-------------------------------------------------------------------------------
 if (Preg_Match($Regulars, $TypeID)) {
     #-------------------------------------------------------------------------------
     # код уведомления совпадает с уведомлением
     $Count = DB_Count(SPrintF('%sOrdersOwners', $Code), array('Where' => SPrintF('`UserID` = %u', $__USER['ID'])));
     if (Is_Error($Count)) {
         return ERROR | @Trigger_Error(500);
     }
     #-------------------------------------------------------------------------------
     if (!$Count) {
         continue;
     }
     #-------------------------------------------------------------------------------
 }
 #-------------------------------------------------------------------------------
 #-------------------------------------------------------------------------------
 if (isset($Type['Title'])) {
Esempio n. 16
0
         }
         #-------------------------------------------------------------------------------
         if ($ServiceField['IsKey']) {
             $Keys[] = $Value;
         }
         #-------------------------------------------------------------------------------
         break;
         #-------------------------------------------------------------------------------
     #-------------------------------------------------------------------------------
     default:
         #-------------------------------------------------------------------------------
         $Regulars = Regulars();
         #-------------------------------------------------------------------------------
         if ($Value || $ServiceField['IsDuty']) {
             #-------------------------------------------------------------------------------
             if (!Preg_Match($Regulars[$ServiceField['ValidatorID']], $Value)) {
                 return new gException('WRONG_FIELD_VALUE', SPrintF('Не верное значение поля (%s) ожидается (%s)', $ServiceField['Name'], $Validators[$ServiceField['ValidatorID']]['Name']));
             }
             #-------------------------------------------------------------------------------
         }
         #-------------------------------------------------------------------------------
         if ($ServiceField['IsKey']) {
             $Keys[] = $Value;
         }
 }
 #-------------------------------------------------------------------------------
 $UOrderField['Value'] = $Value;
 #-------------------------------------------------------------------------------
 #-------------------------------------------------------------------------------
 if (!Is_Null($Value)) {
     #-------------------------------------------------------------------------------
Esempio n. 17
0
#-------------------------------------------------------------------------------
foreach (Preg_Split('/[\\s,]+/', $Text) as $Word) {
    #Debug(SPrintF('[comp/Formats/Edesk/Message/CheckFoul]: Word = "%s"',print_r($Word,true)));
    #-------------------------------------------------------------------------------
    $Word = Trim(Str_Replace($EnCharMap, $RuCharMap, Mb_StrToLower($Word, 'UTF-8')));
    #-------------------------------------------------------------------------------
    if (Mb_StrLen($Word) > $Settings['FoulMaxLength']) {
        continue;
    }
    #-------------------------------------------------------------------------------
    foreach (Preg_Split('/\\s+/', $Regulars['Fouls']) as $Foul) {
        #-------------------------------------------------------------------------------
        $Foul = Trim($Foul);
        #Debug(SPrintF('[comp/Formats/Edesk/Message/CheckFoul]: Foul = "%s"',print_r($Foul,true)));
        #-------------------------------------------------------------------------------
        if (Preg_Match($Foul, $Word)) {
            #-------------------------------------------------------------------------------
            Debug(SPrintF('[comp/Formats/Edesk/Message/CheckFoul]: Foul found: "%s"', $Word));
            return array('Word' => $Word);
            # нецензурщина детектед
            #-------------------------------------------------------------------------------
        }
        #-------------------------------------------------------------------------------
        continue;
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
return TRUE;
Esempio n. 18
0
 # реализация JBS-937
 $Array = array();
 #-------------------------------------------------------------------------------
 if ($AdditionalParams) {
     #-------------------------------------------------------------------------------
     foreach (Explode(",", $AdditionalParams) as $AdditionalParam) {
         #-------------------------------------------------------------------------------
         list($Name, $Value) = Explode("=", Trim($AdditionalParam));
         #-------------------------------------------------------------------------------
         Debug(SPrintF('[comp/Triggers/GLOBAL]: Additional set: %s => %s', $Name, $Value));
         #-------------------------------------------------------------------------------
         # закидываем имя/значение в массив параметров
         $Array[$Name] = $Value;
         #-------------------------------------------------------------------------------
         # проверить динамическое значение параметра, или статическое
         if (Preg_Match('/^%\\w+%$/', $Value)) {
             #-------------------------------------------------------------------------------
             $Column = Str_Replace('%', '', $Value);
             #-------------------------------------------------------------------------------
             Debug(SPrintF('[comp/Triggers/GLOBAL]: Additional need change: Column = %s', $Column));
             #-------------------------------------------------------------------------------
             if (isset($Order['Row'][$Column])) {
                 #-------------------------------------------------------------------------------
                 Debug(SPrintF('[comp/Triggers/GLOBAL]: Additional changed: %s => %s', $Name, $Order['Row'][$Column]));
                 #-------------------------------------------------------------------------------
                 $Array[$Name] = $Order['Row'][$Column];
                 #-------------------------------------------------------------------------------
             } else {
                 #-------------------------------------------------------------------------------
                 Debug(SPrintF('[comp/Triggers/GLOBAL]: $Order->Row->$Column not set, $Order[Row] = %s', print_r($Order['Row'], true)));
                 #-------------------------------------------------------------------------------
Esempio n. 19
0
#-------------------------------------------------------------------------------
unset($BrowsersIDs, $BrowserID);
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
if (!Define('XML_HTTP_REQUEST', isset($_GET['XMLHttpRequest']) || isset($_POST['XMLHttpRequest']))) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$HostID = StrToLower(@$_SERVER['HTTP_HOST']);
#-------------------------------------------------------------------------------
if (Preg_Match('/^www\\.(.+)$/', $HostID, $Mathces)) {
    $HostID = Next($Mathces);
}
#-------------------------------------------------------------------------------
if (Preg_Match('/^(.+)\\:[0-9]+$/', $HostID, $Mathces)) {
    $HostID = Next($Mathces);
}
#-------------------------------------------------------------------------------
if (!Define('HOST_ID', $HostID)) {
    exit('[JBs core]: не удалось определить константу (HOST_ID)');
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
if (!Define('UNIQ_ID', Md5(HOST_ID))) {
    exit('[JBs core]: не удалось определить константу (UNIQ_ID)');
}
#-------------------------------------------------------------------------------
if (!Define('ERROR', 0xabcdef)) {
    exit('[JBs core]: не удалось определить константу (ERROR)');
}
Esempio n. 20
0
function ISPConfig_Scheme_Change($Settings, $Login, $HostingScheme)
{
    /****************************************************************************/
    $__args_types = array('array', 'string', 'array');
    #-----------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /****************************************************************************/
    if ($HostingScheme['PackageID'] == '') {
        $HostingScheme['PackageID'] = 0;
    }
    $ISPConfigPHP = "no";
    if ($HostingScheme['IsPHPFastCGIAccess'] == 'yes') {
        $ISPConfigPHP = $ISPConfigPHP . ",fast-cgi";
    }
    if ($HostingScheme['IsPHPCGIAccess'] == 'yes') {
        $ISPConfigPHP = $ISPConfigPHP . ",cgi";
    }
    if ($HostingScheme['IsPHPModAccess'] == 'yes') {
        $ISPConfigPHP = $ISPConfigPHP . ",mod";
    }
    $Request = array('limit_maildomain' => $HostingScheme['QuotaEmailDomains'], 'limit_mailbox' => $HostingScheme['QuotaEmail'], 'limit_mailforward' => $HostingScheme['QuotaEmailForwards'], 'limit_mailquota' => $HostingScheme['QuotaEmailBox'], 'limit_web_domain' => $HostingScheme['QuotaWWWDomains'], 'limit_web_quota' => $HostingScheme['QuotaDisk'], 'web_php_options' => $ISPConfigPHP, 'limit_cgi' => $HostingScheme['IsCGIAccess'] ? 'y' : 'n', 'limit_ssi' => $HostingScheme['IsSSIAccess'] ? 'y' : 'n', 'limit_ssl' => $HostingScheme['IsSSLAccess'] ? 'y' : 'n', 'limit_web_subdomain' => $HostingScheme['QuotaSubDomains'], 'limit_web_aliasdomain' => $HostingScheme['QuotaParkDomains'], 'limit_ftp_user' => $HostingScheme['QuotaFTP'], 'limit_aps' => $HostingScheme['QuotaWebApp'], 'limit_dns_zone' => $HostingScheme['QuotaWWWDomains'], 'limit_dns_slave_zone' => $HostingScheme['QuotaWWWDomains'], 'limit_database' => $HostingScheme['QuotaDBs'], 'limit_cron' => $HostingScheme['QuotaDomains'], 'limit_traffic_quota' => $HostingScheme['QuotaTraffic'], 'limit_mailmailinglist' => $HostingScheme['QuotaEmailLists'], 'template_master' => $HostingScheme['PackageID']);
    $reseller_id = 0;
    // this id has to be 0 if the client shall not be assigned to admin or if the client is a reseller
    #-----------------------------------------------------------------------------
    # Содаем подключение к панели ISPConfig
    $SoapLocation = SPrintF('%s://%s:%u/remote/index.php', $Settings['Protocol'] == 'ssl' ? 'https' : 'http', $Settings['Address'], $Settings['Port']);
    $SoapUri = SPrintF('%s://%s:%u/remote/', $Settings['Protocol'] == 'ssl' ? 'https' : 'http', $Settings['Address'], $Settings['Port']);
    $client = new SoapClient(null, array('location' => $SoapLocation, 'uri' => $SoapUri, 'trace' => 1, 'exceptions' => 1));
    # Открываем сессию на сервере ISPConfig
    $session_id = $client->login($Settings['Login'], $Settings['Password']);
    #-----------------------------------------------------------------------------
    # Запрашиваем ID клиента по его Имени пользователя
    $client_id = ISPConfig_ClientID($session_id, $client, $Login);
    #-----------------------------------------------------------------------------
    # Запрашиваем параметры клиента
    $Request = ISPConfig_ClientGet($session_id, $client, $client_id, $Request);
    #-----------------------------------------------------------------------------
    # Выполняем отправку данных в панель ISPConfig
    try {
        $client->client_update($session_id, $client_id, $reseller_id, $Request);
        $Response = $client->__getLastResponse();
    } catch (SoapFault $Result) {
        $Response = $client->__getLastResponse();
        $Response = Strip_Tags($Response);
    }
    Debug(SPrintF('Ответ сервера => %s', print_r($Response, true)));
    #-----------------------------------------------------------------------------
    # Закрываем сессию на сервере ISPConfig
    $client->logout($session_id);
    #-----------------------------------------------------------------------------
    # Проверяем на ошибку запроса ответ панели
    if (Preg_Match('/data_processing_error/', $Response)) {
        return new gException('WRONG_ANSWER', $Response);
    } else {
        return TRUE;
    }
}
Esempio n. 21
0
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$IsCheck = array();
#-------------------------------------------------------------------------------
#Debug(SPrintF('[comp/Passwords/Checker]: Password = %s Mode = %s',$Password,$Mode));
#-------------------------------------------------------------------------------
if (isset($Settings[$Mode]['IsActive']) && $Settings[$Mode]['IsActive']) {
    #-------------------------------------------------------------------------------
    if ($Settings[$Mode]['UseLetters']) {
        if (!Preg_Match("/([a-zA-Z]+)/", $Password)) {
            return new gException('NO_LETTERS', 'В пароле должны использоваться буквы английского алфавита!');
        }
    }
    #-------------------------------------------------------------------------------
    if ($Settings[$Mode]['UseDigits']) {
        if (!Preg_Match("/([0-9]+)/", $Password)) {
            return new gException('NO_DIGITS', 'В пароле должны использоваться цифры!');
        }
    }
    #-------------------------------------------------------------------------------
    if ($Settings[$Mode]['Length'] > StrLen($Password)) {
        return new gException('NO_DIGITS', SPrintF('Пароль не должен быть короче %u символов!', $Settings[$Mode]['Length']));
    }
    #-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
return TRUE;
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
Esempio n. 22
0
 #---------------------------------------------------------------------------
 foreach (Array_Keys($Row) as $ColumnID) {
     #-------------------------------------------------------------------------
     if (!isset($Args[$ColumnID])) {
         continue;
     }
     #-------------------------------------------------------------------------
     $Column = $Args[$ColumnID];
     #-------------------------------------------------------------------------
     if ($Column == '[NULL]') {
         $Column = NULL;
     }
     #-------------------------------------------------------------------------
     $TypeID = $ColumnsTypes[$ColumnID]['Type'];
     #-------------------------------------------------------------------------
     if (Preg_Match('/blob/', $TypeID)) {
         #-----------------------------------------------------------------------
         $Upload = Upload_Get($ColumnID);
         #-----------------------------------------------------------------------
         switch (ValueOf($Upload)) {
             case 'error':
                 return ERROR | @Trigger_Error(500);
             case 'exception':
                 # No more...
                 break;
             case 'array':
                 $URow[$ColumnID] = GzCompress($Upload['Data']);
                 break;
             default:
                 return ERROR | @Trigger_Error(101);
         }
Esempio n. 23
0
<?php

#-------------------------------------------------------------------------------
$Folder = SPrintF('%s/hosts/%s', SYSTEM_PATH, HOST_ID);
#-------------------------------------------------------------------------------
$Files = IO_Files($Folder);
if (Is_Error($Files)) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
foreach ($Files as $File) {
    #-----------------------------------------------------------------------------
    if (!Preg_Match('/\\.xml/', $File)) {
        continue;
    }
    #-----------------------------------------------------------------------------
    $Sourse = IO_Read($File);
    if (Is_Error($Sourse)) {
        return ERROR | @Trigger_Error(500);
    }
    #-----------------------------------------------------------------------------
    $Out = Str_Replace('path="MenuLeft"', 'path="Menus/Left"', $Sourse);
    #-----------------------------------------------------------------------------
    if ($Out != $Sourse) {
        #---------------------------------------------------------------------------
        $IsWrite = IO_Write($File, $Out, TRUE);
        if (Is_Error($IsWrite)) {
            return ERROR | @Trigger_Error(500);
        }
    }
}
Esempio n. 24
0
 #-----------------------------------------------------------------------------
 $Files = IO_Files(SPrintF('%s/styles/%s', SYSTEM_PATH, $HostsID));
 if (Is_Error($Files)) {
     return ERROR | @Trigger_Error(500);
 }
 #-----------------------------------------------------------------------------
 if (Count($Files) < 1) {
     continue;
 }
 #-----------------------------------------------------------------------------
 # Все цвета в стиле
 $Finded = array();
 #-----------------------------------------------------------------------------
 foreach ($Files as $File) {
     #---------------------------------------------------------------------------
     if (Preg_Match('/\\/others\\//', $File)) {
         continue;
     }
     #---------------------------------------------------------------------------
     $Sourse = IO_Read($File);
     if (Is_Error($Sourse)) {
         return ERROR | @Trigger_Error(500);
     }
     #---------------------------------------------------------------------------
     if (Preg_Match_All('/#[a-zA-F0-9]{6}/', $Sourse, $Matches) > 1) {
         #-------------------------------------------------------------------------
         foreach (Current($Matches) as $Match) {
             $Finded[Md5($Match)] = Mb_SubStr($Match, 1);
         }
     }
 }
 public function RunChecks()
 {
     if ($this->reportToOutput === false && $this->recipientEmail === null) {
         throw new BadMethodCallException('No reporting defined. Call "ReportToEmail()" or/and "ReportToOutput()" method.');
     }
     if (Count($this->checks) === 0) {
         throw new BadMethodCallException('No checks defined. Add at least one check using "AddCheck()" method.');
     }
     $errors = array();
     foreach ($this->checks as $key => $check) {
         if ($check['pre_url'] !== null) {
             File_Get_Contents($check['pre_url']);
         }
         // just fetch the page, we don't need it's contents
         $response = File_Get_Contents($check['url']);
         if ($response === false) {
             $errors[] = array($check, 'URL not reachable');
             continue;
         }
         $checkFound = false;
         if ($check['is_regex'] === false) {
             $checkFound = StrPos($response, $check['check']) !== false;
         } else {
             $matchResult = Preg_Match($check['check'], $response);
             if ($matchResult === false) {
                 $errors[] = array($check, 'Regular expression is not valid');
                 continue;
             } else {
                 if ($matchResult > 0) {
                     $checkFound = true;
                 }
             }
         }
         if ($checkFound === false) {
             $errors[] = array($check, 'Check string not found');
         }
     }
     if (Count($errors) > 0) {
         $errorsBody = '';
         foreach ($errors as $key => $error) {
             if ($this->recipientEmail !== null) {
                 if ($this->oneEmailPerError === true) {
                     $errorsBody .= $this->getErrorMessage($error) . "\n\n";
                 } else {
                     $this->sendErrorEmail($this->getErrorMessage($error));
                 }
             }
             if ($this->reportToOutput === true) {
                 if ($this->inCli === true) {
                     echo $this->getErrorMessage($error) . "\n\n";
                 } else {
                     echo Nl2Br($this->getErrorMessage($error)) . "<br /><br />";
                 }
             }
         }
         if ($this->recipientEmail !== null && $this->oneEmailPerError === true) {
             $this->sendErrorEmail($errorsBody);
         }
     }
 }
Esempio n. 26
0
 $Attribs = $Profile['Attribs'];
 #-------------------------------------------------------------------------
 #-------------------------------------------------------------------------
 $Attribs['pCountry'] = $Attribs['Country'];
 $Attribs['pState'] = $Attribs['State'];
 $Attribs['pCity'] = $Attribs['City'];
 $Attribs['pAddress'] = Trim(Preg_Replace('/ул./iu', '', $Attribs['Address']));
 $Attribs['AddressEn'] = Translit($Attribs['pAddress']);
 $Attribs['pIndex'] = $Attribs['PostIndex'];
 $Attribs['pRecipient'] = $Attribs['Recipient'];
 #-------------------------------------------------------------------------
 #-------------------------------------------------------------------------
 $Attribs['PasportWhom'] = $Attribs['PasportWhom'];
 $Attribs['PasportDate'] = $Attribs['PasportDate'];
 #-------------------------------------------------------------------------
 if (Preg_Match('/(.*)\\s(.*)$/', $Attribs['PasportNum'], $Matches)) {
     #-----------------------------------------------------------------------
     $Attribs['PasportLine'] = Str_Replace(' ', '', $Matches[1]);
     $Attribs['PasportNum'] = $Matches[2];
 }
 #-------------------------------------------------------------------------
 #-------------------------------------------------------------------------
 $Template = System_XML(SPrintF('profiles/%s.xml', $Profile['TemplateID']));
 if (Is_Error($Template)) {
     return ERROR | @Trigger_Error(500);
 }
 #-------------------------------------------------------------------------
 foreach (Array_Keys($Template['Attribs']) as $AttribID) {
     #-----------------------------------------------------------------------
     if (!isset($Attribs[$AttribID])) {
         $Attribs[$AttribID] = $Template['Attribs'][$AttribID]['Value'];
Esempio n. 27
0
}
#-------------------------------------------------------------------------------
$Logs = SPrintF('%s/logs', $Tmp);
#-------------------------------------------------------------------------------
if (File_Exists($Logs)) {
    #-----------------------------------------------------------------------------
    $Files = IO_Scan($Logs);
    if (Is_Error($Files)) {
        return ERROR | @Trigger_Error(500);
    }
    #-----------------------------------------------------------------------------
    foreach ($Files as $Log) {
        #---------------------------------------------------------------------------
        $Path = SPrintF('%s/%s', $Logs, $Log);
        #---------------------------------------------------------------------------
        if (Preg_Match('/^.+\\.log+$/', $Log)) {
            #-------------------------------------------------------------------------
            if (FileSize($Path) > 1048576) {
                #-----------------------------------------------------------------------
                $Time = Date('[d.m.Y]');
                #-----------------------------------------------------------------------
                if (!ReName($Path, SPrintF('%s/%s%s', $Logs, $Log, $Time))) {
                    return ERROR | @Trigger_Error(SPrintF('[comp/Tasks/Logs]: не удалось произвести ротацию лога (%s)', $Path));
                }
            }
        } else {
            #-------------------------------------------------------------------------
            if (Time() - FileMTime($Path) > 604800) {
                #-----------------------------------------------------------------------
                if (!@UnLink($Path)) {
                    return ERROR | @Trigger_Error(SPrintF('[comp/Tasks/Logs]: не удалось удалить устаревший лог (%s)', $Path));
Esempio n. 28
0
#-------------------------------------------------------------------------------
if (!$Count) {
    return new gException('SERVER_NOT_FOUND', 'Сервер не найден');
}
#-------------------------------------------------------------------------------
$Regulars = Regulars();
#-------------------------------------------------------------------------------
if (!Preg_Match($Regulars['Domain'], $Domain)) {
    return new gException('WRONG_DOMAIN', 'Неверный домен');
}
#-------------------------------------------------------------------------------
if (!$Login) {
    return new gException('LOGIN_NOT_FILLED', 'Логин пользователя не указан');
}
#-------------------------------------------------------------------------------
if (!Preg_Match($Regulars['IP'], $IP)) {
    return new gException('WRONG_IP', 'Неверный IP адрес');
}
#-------------------------------------------------------------------------------
$Server = DB_Select('Servers', array('ID', 'ServersGroupID'), array('UNIQ', 'ID' => $ServerID));
#-------------------------------------------------------------------------------
switch (ValueOf($Server)) {
    case 'error':
        return ERROR | @Trigger_Error(500);
    case 'exception':
        return new gException('SERVER_NOT_FOUND', 'Сервер размещения не найден');
        break;
    case 'array':
        # No more...
        break;
    default:
Esempio n. 29
0
 if (Is_Error($Tmp)) {
     return ERROR | @Trigger_Error(500);
 }
 #-----------------------------------------------------------------------------
 $Public = SPrintF('%s/public', $Tmp);
 #-----------------------------------------------------------------------------
 if (File_Exists($Public)) {
     #---------------------------------------------------------------------------
     $Contents = IO_Scan($Public);
     if (Is_Error($Contents)) {
         return ERROR | @Trigger_Error(500);
     }
     #---------------------------------------------------------------------------
     foreach ($Contents as $Content) {
         #-------------------------------------------------------------------------
         if (Preg_Match('/^statistics/', $Content)) {
             #-----------------------------------------------------------------------
             if (Is_Error(IO_RmDir(SPrintF('%s///%s', $Public, $Content)))) {
                 return ERROR | @Trigger_Error(500);
             }
         }
     }
 }
 #-----------------------------------------------------------------------------
 $UniqID = UniqID('statistics');
 #-----------------------------------------------------------------------------
 $Folder = SPrintF('%s/%s', $Public, $UniqID);
 #-----------------------------------------------------------------------------
 if (!File_Exists($Folder)) {
     #---------------------------------------------------------------------------
     if (!@MkDir($Folder, 0777, TRUE)) {
Esempio n. 30
0
function FindConfigElem(&$cfg_file, $elem_name)
{
    $cfg_info = array();
    $inside = 0;
    for ($i = 0; $i < Count($cfg_file); $i++) {
        $cfg_line = $cfg_file[$i];
        $cfg_line = RTrim($cfg_line);
        $cfg_line = LTrim($cfg_line);
        if (!$cfg_line) {
            // Blank line
            continue;
        } elseif (Preg_Match("/^(\\/\\/|#)/", $cfg_line)) {
            //Comment line
            continue;
        } elseif (Preg_Match("/^(([[:alnum:]]+)\\s+({$elem_name})|{$elem_name})\$/i", $cfg_line, $matches)) {
            $next_line = RTrim($cfg_file[$i + 1]);
            if (!Preg_Match("/\\s*\\{\\s*/i", $next_line)) {
                // Not an elem line - maybe a property line with no spaces infront of it.
                continue;
            }
            //Print("Inside (0){$matches[0]} (1){$matches[1]} (2){$matches[2]} (3){$matches[3]}\n");
            //It is inside the elem that it has been told to read.
            $inside = 1;
        } elseif ($inside) {
            if (Preg_Match("/^{/i", $cfg_line)) {
                //Ignore the { line
                continue;
            } elseif (Preg_Match("/^}/i", $cfg_line)) {
                //It reached the } line, which means it is done reading the elem.
                //Stop going through the rest of the file at this point.
                $inside = 0;
                break;
            } else {
                //It is still inside the elem's brackets.
                //Split the lines up into key value pairs.
                //Tuck the values into the array[key]
                $info = Preg_Split("/\\s+/", $cfg_line, 2, PREG_SPLIT_NO_EMPTY);
                $key = $info[0];
                $value = $info[1];
                if (!Is_Array($cfg_info[$key])) {
                    // If cfg_info[key] is not already an array,
                    // make it one so it can hold multiple values.
                    $cfg_info[$key] = array();
                }
                Array_Push($cfg_info[$key], $value);
            }
        }
    }
    if (Count($cfg_info) < 1) {
        return FALSE;
    } else {
        return $cfg_info;
    }
}