Ejemplo n.º 1
0
 public function Load($TemplateID)
 {
     /****************************************************************************/
     $__args_types = array('string');
     #-----------------------------------------------------------------------------
     $__args__ = Func_Get_Args();
     eval(FUNCTION_INIT);
     /****************************************************************************/
     foreach ($__args__ as $__arg__) {
         #---------------------------------------------------------------------------
         $this->TemplateID = $__arg__;
         #---------------------------------------------------------------------------
         $Path = System_Element(SPrintF('templates/%s.xml', $__arg__));
         if (!Is_Error($Path)) {
             #-------------------------------------------------------------------------
             $Source = IO_Read($Path);
             if (Is_Error($Source)) {
                 return ERROR | @Trigger_Error('[DOM->Load]: не удалось загрузить файл шаблона');
             }
             #-------------------------------------------------------------------------
             $this->Object = String_XML_Parse($Source);
             if (Is_Exception($this->Object)) {
                 return ERROR | @Trigger_Error('[DOM->Load]: не удалось преобразовать XML');
             }
             #-------------------------------------------------------------------------
             $this->Object = Current($this->Object->Childs);
             #-------------------------------------------------------------------------
             $this->Linking();
             #-------------------------------------------------------------------------
             break;
         }
     }
     #-----------------------------------------------------------------------------
     $Trigger = SPrintF('Triggers/DOM/Before/%s', $this->TemplateID);
     #-----------------------------------------------------------------------------
     if ($this->TemplateID) {
         #---------------------------------------------------------------------------
         if (!Is_Error(System_Element(SPrintF('comp/%s.comp.php', $Trigger)))) {
             #-------------------------------------------------------------------------
             $LinkID = UniqID('DOM-');
             #-------------------------------------------------------------------------
             $Links =& Links();
             # Коллекция ссылок
             $Links[$LinkID] =& $this;
             #-------------------------------------------------------------------------
             $Comp = Comp_Load($Trigger, $LinkID, COMP_ALL_HOSTS);
             if (Is_Error($Comp)) {
                 return ERROR | @Trigger_Error('[DOM->Load]: ошибка загрузки предобработчика');
             }
             #-------------------------------------------------------------------------
             unset($Links[$LinkID]);
         }
     }
     #-----------------------------------------------------------------------------
     return TRUE;
 }
Ejemplo n.º 2
0
     echo "Файл базы данных является сжатым файлом gzip\n";
     #-------------------------------------------------------------------------
     $Data = $gZip;
 } else {
     echo "Файл базы данных не является сжатым файлом gzip\n";
 }
 #---------------------------------------------------------------------------
 $File = rTrim($Upload['Name'], '.gz');
 #---------------------------------------------------------------------------
 $File = PathInfo($File);
 #---------------------------------------------------------------------------
 switch (StrToLower($File['extension'])) {
     case 'xml':
         #-----------------------------------------------------------------------
         $Data = String_XML_Parse($Data);
         if (Is_Exception($Data)) {
             return SPrintF('Ошибка чтения базы данных: (%s)', $Data->String);
         }
         #-----------------------------------------------------------------------
         break;
     case 'serialize':
         #-----------------------------------------------------------------------
         $Data = UnSerialize($Data);
         if (!$Data) {
             return 'Ошибка чтения базы данных';
         }
         #-----------------------------------------------------------------------
         break;
     default:
         return 'Не верный формат файла';
 }
Ejemplo n.º 3
0
function Plesk_Password_Change($Settings, $Login, $Password, $Params)
{
    /****************************************************************************/
    $__args_types = array('array', 'string', 'string', 'array');
    #-----------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /****************************************************************************/
    $packet = new Tag('packet', array('version' => '1.4.2.0'));
    #-----------------------------------------------------------------------------
    $set = new Tag('set', new Tag('filter', new Tag('login', $Login)), new Tag('values', new Tag('gen_info', new Tag('passwd', $Password))));
    #-----------------------------------------------------------------------------
    $packet->AddChild(new Tag('client', $set));
    #-----------------------------------------------------------------------------
    $Request = SPrintF("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n%s", $packet->ToXMLString());
    #-----------------------------------------------------------------------------
    $Headers = array('Content-Type: text/xml', SPrintF('HTTP_AUTH_LOGIN: %s', $Settings['Login']), SPrintF('HTTP_AUTH_PASSWD: %s', $Settings['Password']));
    #-----------------------------------------------------------------------------
    $HTTP = array('Address' => $Settings['IP'], 'Port' => $Settings['Port'], 'Host' => $Settings['Address'], 'Protocol' => $Settings['Protocol'], 'Hidden' => $Settings['Password'], 'IsLogging' => $Settings['Params']['IsLogging']);
    #-----------------------------------------------------------------------------
    $Response = HTTP_Send('/enterprise/control/agent.php', $HTTP, array(), $Request, $Headers);
    if (Is_Error($Response)) {
        return ERROR | @Trigger_Error('[Plesk_Password_Change]: не удалось соедениться с сервером');
    }
    #-----------------------------------------------------------------------------
    $Response = Trim($Response['Body']);
    #-----------------------------------------------------------------------------
    $XML = String_XML_Parse($Response);
    if (Is_Exception($XML)) {
        return new gException('WRONG_SERVER_ANSWER', $Response, $XML);
    }
    #-----------------------------------------------------------------------------
    $XML = $XML->ToArray();
    #-----------------------------------------------------------------------------
    $Result = $XML['packet']['client']['set']['result'];
    #-----------------------------------------------------------------------------
    switch ($Result['status']) {
        case 'ok':
            return TRUE;
        case 'error':
            #--------------------------------------------------------------------------
            Debug(SPrintF('[%u]=(%s)', $Result['errcode'], $Result['errtext']));
            #--------------------------------------------------------------------------
            return new gException('SERVER_ERROR', Trim($Result['errtext']));
        default:
            return new gException('WRONG_ANSWER', 'Неизвестный ответ');
    }
}
Ejemplo n.º 4
0
#-------------------------------------------------------------------------------
/** @author Alex Keda, for www.host-food.ru */
/******************************************************************************/
/******************************************************************************/
$ConfigPath = SPrintF('%s/hosts/%s/config/Config.xml', SYSTEM_PATH, HOST_ID);
#-------------------------------------------------------------------------------
if (File_Exists($ConfigPath)) {
    #-------------------------------------------------------------------------------
    $File = IO_Read($ConfigPath);
    if (Is_Error($File)) {
        return ERROR | @Trigger_Error(500);
    }
    #-------------------------------------------------------------------------------
    $XML = String_XML_Parse($File);
    if (Is_Exception($XML)) {
        return ERROR | @Trigger_Error(500);
    }
    #-------------------------------------------------------------------------------
    $Config = $XML->ToArray();
    #-------------------------------------------------------------------------------
    $Config = $Config['XML'];
    #-------------------------------------------------------------------------------
} else {
    #-------------------------------------------------------------------------------
    $Config = array();
    #-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
if (isset($Config['Tasks']['Types']['CheckEmail']['CheckEmailLogin'])) {
Ejemplo n.º 5
0
function Started_Contract_Register($Settings, $PepsonID, $Person, $DomainZone)
{
    /****************************************************************************/
    $__args_types = array('array', 'string', 'array', 'string');
    #-----------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /****************************************************************************/
    $HTTP = array('Protocol' => $Settings['Protocol'], 'Port' => $Settings['Port'], 'Address' => $Settings['Address'], 'Host' => $Settings['Address'], 'IsLogging' => $Settings['Params']['IsLogging']);
    #-----------------------------------------------------------------------------
    $Reseller = new Tag('reseller');
    $Reseller->AddChild(new Tag('login', $Settings['Login']));
    $Reseller->AddChild(new Tag('password', $Settings['Password']));
    #-----------------------------------------------------------------------------
    $Tmp = System_Element('tmp');
    if (Is_Error($Tmp)) {
        return ERROR | @Trigger_Error(500);
    }
    #-----------------------------------------------------------------------------
    $pCountry = isset($Person['PasportCountry']) ? $Person['PasportCountry'] : $Person['pCountry'];
    #-----------------------------------------------------------------------------
    $Path = SPrintF('%s/started/states[%s].json', $Tmp, $pCountry);
    #-----------------------------------------------------------------------------
    if (File_Exists($Path)) {
        #---------------------------------------------------------------------------
        $States = IO_Read($Path);
        if (Is_Error($States)) {
            return ERROR | @Trigger_Error(500);
        }
        #---------------------------------------------------------------------------
        $States = JSON_Decode($States, TRUE);
        if (!$States) {
            return ERROR | @Trigger_Error(500);
        }
    } else {
        #---------------------------------------------------------------------------
        $Request = new Tag('RequestBody', $Reseller);
        #---------------------------------------------------------------------------
        $objCountry = new Tag('objCountry');
        $objCountry->AddChild(new Tag('method', 'getRegions'));
        $objCountry->AddChild(new Tag('country', $pCountry));
        #---------------------------------------------------------------------------
        $Request->AddChild($objCountry);
        #---------------------------------------------------------------------------
        $Post = SprintF("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n%s", $Request->ToXMLString());
        #---------------------------------------------------------------------------
        $Responce = HTTP_Send('/', $HTTP, array(), $Post, array('Content-type: text/xml'));
        if (Is_Error($Responce)) {
            return ERROR | @Trigger_Error(500);
        }
        #---------------------------------------------------------------------------
        $Response = Trim($Responce['Body']);
        #---------------------------------------------------------------------------
        $Answer = String_XML_Parse($Response);
        if (Is_Exception($Answer)) {
            return new gException('WRONG_ANSWER', $Response, $Answer);
        }
        #---------------------------------------------------------------------------
        $States = Current($States->ToArray('item'));
        #---------------------------------------------------------------------------
        $IsWrite = IO_Write($Path, JSON_Encode($States), TRUE);
        if (Is_Error($IsWrite)) {
            return ERROR | @Trigger_Error(500);
        }
    }
    #-----------------------------------------------------------------------------
    $objUser = new Tag('objUser');
    $objUser->AddChild(new Tag('method', 'create'));
    #-----------------------------------------------------------------------------
    $objUser->AddChild(new Tag('email', $Person['Email']));
    $objUser->AddChild(new Tag('password', SubStr(Md5(UniqID()), -8)));
    #-----------------------------------------------------------------------------
    $IsRussian = In_Array(isset($Person['PasportCountry']) ? $Person['PasportCountry'] : $Person['pCountry'], array('RU', 'BY', 'UA'));
    #-----------------------------------------------------------------------------
    switch ($PepsonID) {
        case 'Natural':
            #-------------------------------------------------------------------------
            $pStateID = 0;
            #-------------------------------------------------------------------------
            $pState = $Person['pState'];
            #-------------------------------------------------------------------------
            foreach ($States as $State) {
                #-----------------------------------------------------------------------
                if (Preg_Match(SPrintF('/%s/', StrToLower($State['title'])), StrToLower($pState))) {
                    #---------------------------------------------------------------------
                    $pStateID = $State['id'];
                    #---------------------------------------------------------------------
                    Debug(SPrintF('Найдена область: %s', $pStateID));
                    #---------------------------------------------------------------------
                    break;
                }
            }
            #-------------------------------------------------------------------------
            if (!$pStateID) {
                #-----------------------------------------------------------------------
                Debug(SPrintF('Область не найдена, проверьте название области (%s)', $pState));
                #-----------------------------------------------------------------------
                return new gException('POST_REGION_NOT_FOUND', 'Область почтового адреса не найдена');
            }
            #-------------------------------------------------------------------------
            $objUser->AddChild(new Tag('type', 'person'));
            #-------------------------------------------------------------------------
            if ($IsRussian) {
                #-----------------------------------------------------------------------
                $objUser->AddChild(new Tag('fname', $Person['Name']));
                $objUser->AddChild(new Tag('lname', $Person['Lastname']));
                $objUser->AddChild(new Tag('mname', $Person['Sourname']));
                $objUser->AddChild(new Tag('doc_issued', $Person['PasportWhom']));
            } else {
                $objUser->AddChild(new Tag('fname', Translit($Person['Name'])));
                $objUser->AddChild(new Tag('lname', Translit($Person['Lastname'])));
                $objUser->AddChild(new Tag('mname', Translit($Person['Sourname'])));
                $objUser->AddChild(new Tag('doc_issued', Translit($Person['PasportWhom'])));
            }
            #-------------------------------------------------------------------------
            $objUser->AddChild(new Tag('p_inn', ''));
            $objUser->AddChild(new Tag('doc_serial', $Person['PasportLine']));
            $objUser->AddChild(new Tag('doc_number', $Person['PasportNum']));
            $objUser->AddChild(new Tag('doc_date', $Person['PasportDate']));
            $objUser->AddChild(new Tag('birth_date', $Person['BornDate']));
            #-------------------------------------------------------------------------
            $objUser->AddChild(new Tag('country', StrToLower(isset($Person['PasportCountry']) ? $Person['PasportCountry'] : $Person['pCountry'])));
            #-------------------------------------------------------------------------
            $objUser->AddChild(new Tag('zip', $Person['pIndex']));
            $objUser->AddChild(new Tag('state', $pStateID));
            $objUser->AddChild(new Tag('city_type', 'city'));
            $objUser->AddChild(new Tag('addr_type', StrToLower($Person['pType'])));
            #-------------------------------------------------------------------------
            if ($IsRussian) {
                #-----------------------------------------------------------------------
                $objUser->AddChild(new Tag('city', $Person['pCity']));
                $objUser->AddChild(new Tag('addr', SPrintF('%s %s', $Person['pType'], $Person['pAddress'])));
            } else {
                $objUser->AddChild(new Tag('city', Translit($Person['pCity'])));
                $objUser->AddChild(new Tag('addr', Translit(SPrintF('%s %s', $Person['pType'], $Person['pAddress']))));
            }
            #-------------------------------------------------------------------------
            $objUser->AddChild(new Tag('pzip', $Person['pIndex']));
            $objUser->AddChild(new Tag('pstate', $pStateID));
            $objUser->AddChild(new Tag('pcity_type', 'city'));
            $objUser->AddChild(new Tag('paddr_type', StrToLower($Person['pType'])));
            #-------------------------------------------------------------------------
            if ($IsRussian) {
                #-----------------------------------------------------------------------
                $objUser->AddChild(new Tag('pcity', $Person['pCity']));
                $objUser->AddChild(new Tag('paddr', SPrintF('%s %s', $Person['pType'], $Person['pAddress'])));
                $objUser->AddChild(new Tag('pto', $Person['pRecipient']));
            } else {
                #-----------------------------------------------------------------------
                $objUser->AddChild(new Tag('pcity', Translit($Person['pCity'])));
                $objUser->AddChild(new Tag('paddr', Translit(SPrintF('%s %s', $Person['pType'], $Person['pAddress']))));
                $objUser->AddChild(new Tag('pto', Translit($Person['pRecipient'])));
            }
            break;
        case 'Juridical':
            #-------------------------------------------------------------------------
            $objUser->AddChild(new Tag('type', 'organization'));
            #-------------------------------------------------------------------------
            if ($IsRussian) {
                #-----------------------------------------------------------------------
                $objUser->AddChild(new Tag('fname', $Person['dName']));
                $objUser->AddChild(new Tag('lname', $Person['dLastname']));
                $objUser->AddChild(new Tag('mname', $Person['dSourname']));
                $objUser->AddChild(new Tag('org', SPrintF('%s "%s"', $Person['CompanyFormFull'], $Person['CompanyName'])));
            } else {
                $objUser->AddChild(new Tag('fname', Translit($Person['dName'])));
                $objUser->AddChild(new Tag('lname', Translit($Person['dLastname'])));
                $objUser->AddChild(new Tag('mname', Translit($Person['dSourname'])));
                $objUser->AddChild(new Tag('org', SPrintF('%s %s', Translit($Person['CompanyName']), Translit($Person['CompanyFormFull']))));
            }
            #-------------------------------------------------------------------------
            $objUser->AddChild(new Tag('o_inn', $Person['Inn']));
            $objUser->AddChild(new Tag('kpp', $Person['Kpp']));
            #-------------------------------------------------------------------------
            $objUser->AddChild(new Tag('country', StrToLower($Person['jCountry'])));
            #-------------------------------------------------------------------------
            $objUser->AddChild(new Tag('zip', $Person['jIndex']));
            #-------------------------------------------------------------------------
            $jStateID = 0;
            #-------------------------------------------------------------------------
            $jState = $Person['jState'];
            #-------------------------------------------------------------------------
            foreach ($States as $State) {
                #-----------------------------------------------------------------------
                if (Preg_Match(SPrintF('/%s/', StrToLower($State['title'])), StrToLower($jState))) {
                    #---------------------------------------------------------------------
                    $jStateID = $State['id'];
                    #---------------------------------------------------------------------
                    Debug(SPrintF('Найдена область: %s', $jStateID));
                    #---------------------------------------------------------------------
                    break;
                }
            }
            #-------------------------------------------------------------------------
            if (!$jStateID) {
                #-----------------------------------------------------------------------
                Debug(SPrintF('Область не найдена, проверьте название области (%s)', $jState));
                #-----------------------------------------------------------------------
                return new gException('JURIDICAL_REGION_NOT_FOUND', 'Область юридического адреса не найдена');
            }
            #-------------------------------------------------------------------------
            $objUser->AddChild(new Tag('state', $jStateID));
            $objUser->AddChild(new Tag('city_type', 'city'));
            $objUser->AddChild(new Tag('addr_type', StrToLower($Person['jType'])));
            #-------------------------------------------------------------------------
            if ($IsRussian) {
                #-----------------------------------------------------------------------
                $objUser->AddChild(new Tag('city', $Person['jCity']));
                $objUser->AddChild(new Tag('addr', SPrintF('%s %s', $Person['jType'], $Person['jAddress'])));
            } else {
                $objUser->AddChild(new Tag('city', Translit($Person['jCity'])));
                $objUser->AddChild(new Tag('addr', Translit(SPrintF('%s %s', $Person['jType'], $Person['jAddress']))));
            }
            #-------------------------------------------------------------------------
            $objUser->AddChild(new Tag('pzip', $Person['pIndex']));
            #-------------------------------------------------------------------------
            $pStateID = 0;
            #-------------------------------------------------------------------------
            $pState = $Person['pState'];
            #-------------------------------------------------------------------------
            foreach ($States as $State) {
                #-----------------------------------------------------------------------
                if (Preg_Match(SPrintF('/%s/', StrToLower($State['title'])), StrToLower($pState))) {
                    #---------------------------------------------------------------------
                    $pStateID = $State['id'];
                    #---------------------------------------------------------------------
                    Debug(SPrintF('Найдена область: %s', $pStateID));
                    #---------------------------------------------------------------------
                    break;
                }
            }
            #-------------------------------------------------------------------------
            if (!$pStateID) {
                #-----------------------------------------------------------------------
                Debug(SPrintF('Область не найдена, проверьте название области (%s)', $pState));
                #-----------------------------------------------------------------------
                return new gException('POST_REGION_NOT_FOUND', 'Область почтового адреса не найдена');
            }
            #-------------------------------------------------------------------------
            $objUser->AddChild(new Tag('pstate', $pStateID));
            $objUser->AddChild(new Tag('pcity_type', 'city'));
            $objUser->AddChild(new Tag('paddr_type', StrToLower($Person['pType'])));
            #-------------------------------------------------------------------------
            if ($IsRussian) {
                #-----------------------------------------------------------------------
                $objUser->AddChild(new Tag('pcity', $Person['pCity']));
                $objUser->AddChild(new Tag('paddr', SPrintF('%s %s', $Person['pType'], $Person['pAddress'])));
                $objUser->AddChild(new Tag('pto', SPrintF('%s "%s"', $Person['CompanyFormFull'], $Person['CompanyName'])));
            } else {
                $objUser->AddChild(new Tag('pcity', Translit($Person['pCity'])));
                $objUser->AddChild(new Tag('paddr', Translit(SPrintF('%s %s', $Person['pType'], $Person['pAddress']))));
                $objUser->AddChild(new Tag('pto', SPrintF('%s %s', Translit($Person['CompanyName']), Translit($Person['CompanyFormFull']))));
            }
            break;
        default:
            return ERROR | @Trigger_Error(101);
    }
    #-----------------------------------------------------------------------------
    $Phone = $Person['Phone'];
    #-----------------------------------------------------------------------------
    if ($Phone) {
        #---------------------------------------------------------------------------
        $Phone = StrPBrk($Phone, ' ');
        #---------------------------------------------------------------------------
        $objUser->AddChild(new Tag('tel', Trim($Phone)));
    } else {
        $objUser->AddChild(new Tag('tel'));
    }
    #-----------------------------------------------------------------------------
    $Fax = $Person['Fax'];
    #-----------------------------------------------------------------------------
    if ($Fax) {
        #---------------------------------------------------------------------------
        $Fax = StrPBrk($Fax, ' ');
        #---------------------------------------------------------------------------
        $objUser->AddChild(new Tag('fax', Trim($Fax)));
    } else {
        $objUser->AddChild(new Tag('fax'));
    }
    #-----------------------------------------------------------------------------
    $Request = new Tag('RequestBody', $Reseller);
    #-----------------------------------------------------------------------------
    $Request->AddChild($objUser);
    #-----------------------------------------------------------------------------
    $Post = SprintF("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n%s", $Request->ToXMLString());
    #-----------------------------------------------------------------------------
    $Responce = HTTP_Send('/', $HTTP, array(), $Post, array('Content-type: text/xml; charset=utf-8'));
    if (Is_Error($Responce)) {
        return ERROR | @Trigger_Error(500);
    }
    #-----------------------------------------------------------------------------
    $Response = Trim($Responce['Body']);
    #-----------------------------------------------------------------------------
    $Answer = String_XML_Parse($Response);
    if (Is_Exception($Answer)) {
        return new gException('WRONG_ANSWER', $Response, $Answer);
    }
    #-----------------------------------------------------------------------------
    $Answer = $Answer->ToArray();
    #-----------------------------------------------------------------------------
    $Answer = $Answer['AnswerBody'];
    #-----------------------------------------------------------------------------
    if (isset($Answer['statusCode'])) {
        return new gException('REGISTRATOR_ERROR', SPrintF('[%s]=(%s)', $Answer['statusCode'], $Answer['statusMessage']));
    }
    #-----------------------------------------------------------------------------
    return array('TicketID' => $Answer['user_id']);
}
Ejemplo n.º 6
0
function Styles_XML($Element)
{
    /****************************************************************************/
    $__args_types = array('string');
    #-----------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /****************************************************************************/
    $CacheID = SPrintF('Styles_XML[%s]', Md5($Element));
    #-----------------------------------------------------------------------------
    $Result = CacheManager::get($CacheID);
    if ($Result) {
        return $Result;
    }
    #-----------------------------------------------------------------------------
    $HostsIDs = Styles_HostsIDs($Element);
    if (Is_Error($HostsIDs)) {
        return ERROR | @Trigger_Error('[Styles_XML]: список хостов содержащих элемент не найдены');
    }
    #-----------------------------------------------------------------------------
    $Result = array();
    #-----------------------------------------------------------------------------
    foreach (Array_Reverse($HostsIDs) as $HostID) {
        #---------------------------------------------------------------------------
        $Path = SPrintF('%s/styles/%s/%s', SYSTEM_PATH, $HostID, $Element);
        #---------------------------------------------------------------------------
        $File = IO_Read($Path);
        if (Is_Error($File)) {
            return ERROR | @Trigger_Error('[Styles_XML]: не удалось прочитать XML-файл');
        }
        #---------------------------------------------------------------------------
        $XML = String_XML_Parse($File);
        if (Is_Exception($XML)) {
            return ERROR | @Trigger_Error('[Styles_XML]: не удалось разобрать XML-строку');
        }
        #---------------------------------------------------------------------------
        $Child = Current($XML->Childs);
        #---------------------------------------------------------------------------
        if (isset($Child->Attribs['recursive'])) {
            $Result = array();
        }
        #---------------------------------------------------------------------------
        $Adding = $XML->ToArray();
        #---------------------------------------------------------------------------
        $Adding = $Adding['XML'];
        #---------------------------------------------------------------------------
        Array_Union($Result, $Adding);
    }
    #-----------------------------------------------------------------------------
    CacheManager::add($CacheID, $Result);
    #-----------------------------------------------------------------------------
    return $Result;
}
Ejemplo n.º 7
0
function IspManager4_Check_Version($Settings)
{
    /******************************************************************************/
    $__args_types = array('array', 'string');
    #-------------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /******************************************************************************/
    $HTTP = IspManager4_Build_HTTP($Settings);
    #-------------------------------------------------------------------------------
    $authinfo = SPrintF('%s:%s', $Settings['Login'], $Settings['Password']);
    #-------------------------------------------------------------------------------
    # достаём информацию о лицензии
    $Response = HTTP_Send('/ispmgr', $HTTP, array(), array('authinfo' => $authinfo, 'out' => 'xml', 'func' => 'softinfo'));
    if (Is_Error($Response)) {
        return new gException('NOT_CONNECTED_TO_SERVER', 'Не удалось соедениться с сервером');
    }
    #-------------------------------------------------------------------------------
    $Response = Trim($Response['Body']);
    #-------------------------------------------------------------------------------
    $XML = String_XML_Parse($Response);
    if (Is_Exception($XML)) {
        return new gException('WRONG_SERVER_ANSWER', $Response, $XML);
    }
    #-------------------------------------------------------------------------------
    $XML = $XML->ToArray();
    #-------------------------------------------------------------------------------
    $Info = $XML['doc'];
    #-------------------------------------------------------------------------------
    if (isset($Info['error'])) {
        return new gException('GET_LICENSE_INFO_ERROR', $Info['error']);
    }
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    return Preg_Match('/Lite/', $Info['mgrver']) ? 'Lite' : 'Pro';
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
}
Ejemplo n.º 8
0
 $Replace = array('HOST_ID' => HOST_ID, 'Clause' => array('ID' => $Clause['ID']));
 #---------------------------------------------------------------------------
 if (isset($GLOBALS['__USER'])) {
     $Replace['__USER'] = $GLOBALS['__USER'];
 }
 #---------------------------------------------------------------------------
 $Replace = Array_ToLine($Replace, '%');
 #---------------------------------------------------------------------------
 foreach (Array_Keys($Replace) as $Key) {
     $Text = Str_Replace($Key, $Replace[$Key], $Text);
 }
 #---------------------------------------------------------------------------
 if ($Clause['IsDOM']) {
     #-------------------------------------------------------------------------
     $DOM = String_XML_Parse($Text);
     if (Is_Exception($DOM)) {
         return ERROR | @Trigger_Error(500);
     }
     #-------------------------------------------------------------------------
     $DOM = Current($DOM->Childs);
 } else {
     $DOM = new Tag('DIV', array('force-escape' => 'yes'), $Text);
 }
 #---------------------------------------------------------------------------
 $Result['DOM'] = $DOM;
 #---------------------------------------------------------------------------
 if ($IsEdit) {
     #-------------------------------------------------------------------------
     if (isset($GLOBALS['__USER'])) {
         #-----------------------------------------------------------------------
         $Permission = Permission_Check('ClauseEdit', (int) $GLOBALS['__USER']['ID'], (int) $Clause['AuthorID']);
Ejemplo n.º 9
0
    return ERROR | @Trigger_Error(700);
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$Regulars = Regulars();
#-------------------------------------------------------------------------------
if (!Preg_Match($Regulars['Password'], $Password)) {
    return new gException('WRONG_PASSWORD', 'Неверно указан новый пароль');
}
#-------------------------------------------------------------------------------
$IsCheck = Comp_Load('Passwords/Checker', $Password, 'Change');
if (Is_Error($IsCheck)) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
if (Is_Exception($IsCheck)) {
    return $IsCheck;
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$User = DB_Select('Users', 'ID', array('UNIQ', 'ID' => $UserID ? $UserID : $GLOBALS['__USER']['ID']));
#-------------------------------------------------------------------------------
switch (ValueOf($User)) {
    case 'error':
        return ERROR | @Trigger_Error(500);
    case 'exception':
        return ERROR | @Trigger_Error(400);
    case 'array':
        break;
    default:
        return ERROR | @Trigger_Error(101);
Ejemplo n.º 10
0
function VmManager5_KVM_Get_DiskTemplates($Settings)
{
    /****************************************************************************/
    $__args_types = array('array');
    #-----------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /****************************************************************************/
    $authinfo = SPrintF('%s:%s', $Settings['Login'], $Settings['Password']);
    #-----------------------------------------------------------------------------
    $HTTP = VmManager5_KVM_Build_HTTP($Settings);
    #-----------------------------------------------------------------------------
    $Response = HTTP_Send('/vmmgr', $HTTP, array(), array('authinfo' => $authinfo, 'out' => 'xml', 'func' => 'osmgr'));
    if (Is_Error($Response)) {
        return ERROR | @Trigger_Error('[VmManager5_Get_DiskTemplates]: не удалось соедениться с сервером');
    }
    #-----------------------------------------------------------------------------
    $Response = Trim($Response['Body']);
    #-----------------------------------------------------------------------------
    $XML = String_XML_Parse($Response);
    if (Is_Exception($XML)) {
        return new gException('WRONG_SERVER_ANSWER', $Response, $XML);
    }
    #-----------------------------------------------------------------------------
    $XML = $XML->ToArray('elem');
    #-----------------------------------------------------------------------------
    $Templates = $XML['doc'];
    #-----------------------------------------------------------------------------
    if (isset($Templates['error'])) {
        return new gException('GET_TEMPLATES_ERROR', $Templates['error']);
    }
    #-----------------------------------------------------------------------------
    $Result = array();
    #-----------------------------------------------------------------------------
    foreach ($Templates as $Template) {
        #-----------------------------------------------------------------------------
        if (!isset($Template['id'])) {
            continue;
        }
        #-----------------------------------------------------------------------------
        if (!isset($Template['name'])) {
            continue;
        }
        #-----------------------------------------------------------------------------
        if (!isset($Template['installed']) || $Template['installed'] != 'on') {
            continue;
        }
        #-----------------------------------------------------------------------------
        if ($Template['restrict'] != 'off') {
            continue;
        }
        #-----------------------------------------------------------------------------
        $Result[] = $Template['name'];
        #-----------------------------------------------------------------------------
    }
    #-----------------------------------------------------------------------------
    #-----------------------------------------------------------------------------
    return $Result;
    #-----------------------------------------------------------------------------
    #-----------------------------------------------------------------------------
}
Ejemplo n.º 11
0
 function AddHTML($Html, $IsAfter = FALSE)
 {
     /****************************************************************************/
     $__args_types = array('string', 'boolean');
     #-----------------------------------------------------------------------------
     $__args__ = Func_Get_Args();
     eval(FUNCTION_INIT);
     /****************************************************************************/
     $Object = String_XML_Parse($Html);
     if (Is_Exception($Object)) {
         return ERROR | Trigger_Error('[Tag->AddHTML]: не удалось преобразовать объект');
     }
     #-----------------------------------------------------------------------------
     $Childs = $IsAfter ? Array_Reverse($Object->Childs) : $Object->Childs;
     #-----------------------------------------------------------------------------
     $Result = array();
     #-----------------------------------------------------------------------------
     foreach ($Childs as $Child) {
         $Result[] =& $this->AddChild($Child, $IsAfter);
     }
     #-----------------------------------------------------------------------------
     return $Result;
 }
Ejemplo n.º 12
0
function VdsManager4_Get_DiskTemplates($Settings)
{
    /****************************************************************************/
    $__args_types = array('array');
    #-----------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /****************************************************************************/
    $authinfo = SPrintF('%s:%s', $Settings['Login'], $Settings['Password']);
    #-----------------------------------------------------------------------------
    $HTTP = array('Address' => $Settings['Params']['IP'], 'Port' => $Settings['Port'], 'Host' => $Settings['Address'], 'Protocol' => $Settings['Protocol'], 'Hidden' => $authinfo, 'IsLogging' => $Settings['Params']['IsLogging']);
    #-----------------------------------------------------------------------------
    $Response = HTTP_Send('/manager/vdsmgr', $HTTP, array(), array('authinfo' => $authinfo, 'out' => 'xml', 'func' => 'disktempl'));
    if (Is_Error($Response)) {
        return ERROR | @Trigger_Error('[VdsManager4_Get_DiskTemplates]: не удалось соедениться с сервером');
    }
    #-----------------------------------------------------------------------------
    $Response = Trim($Response['Body']);
    #-----------------------------------------------------------------------------
    $XML = String_XML_Parse($Response);
    if (Is_Exception($XML)) {
        return new gException('WRONG_SERVER_ANSWER', $Response, $XML);
    }
    #-----------------------------------------------------------------------------
    $XML = $XML->ToArray('elem');
    #-----------------------------------------------------------------------------
    $Templates = $XML['doc'];
    #-----------------------------------------------------------------------------
    if (isset($Templates['error'])) {
        return new gException('GET_TEMPLATES_ERROR', $Templates['error']);
    }
    #-----------------------------------------------------------------------------
    $Result = array();
    #-----------------------------------------------------------------------------
    foreach ($Templates as $Template) {
        #-----------------------------------------------------------------------------
        if (!isset($Template['name'])) {
            continue;
        }
        #-----------------------------------------------------------------------------
        if ($Template['state'] != 'ok') {
            continue;
        }
        #-----------------------------------------------------------------------------
        $Result[] = $Template['name'];
        #-----------------------------------------------------------------------------
    }
    #-----------------------------------------------------------------------------
    return $Result;
    #-----------------------------------------------------------------------------
}
Ejemplo n.º 13
0
function DNSmanager5_Password_Change($Settings, $Login, $Password, $Params)
{
    /******************************************************************************/
    $__args_types = array('array', 'string', 'string', 'array');
    #-------------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /******************************************************************************/
    $authinfo = SPrintF('%s:%s', $Settings['Login'], $Settings['Password']);
    #-------------------------------------------------------------------------------
    $HTTP = array('Address' => $Settings['Address'], 'Port' => $Settings['Port'], 'Host' => $Settings['Address'], 'Protocol' => $Settings['Protocol'], 'Hidden' => $authinfo, 'IsLogging' => $Settings['Params']['IsLogging']);
    #-------------------------------------------------------------------------------
    $Request = array('authinfo' => $authinfo, 'out' => 'xml', 'func' => 'usrparam', 'su' => $Login, 'sok' => 'ok', 'atype' => 'atany', 'password' => $Password, 'confirm' => $Password);
    #-------------------------------------------------------------------------------
    $Response = HTTP_Send('/dnsmgr', $HTTP, array(), $Request);
    if (Is_Error($Response)) {
        return ERROR | @Trigger_Error('[DNSmanager5_Password_Change]: не удалось соедениться с сервером');
    }
    #-------------------------------------------------------------------------------
    $Response = Trim($Response['Body']);
    #-------------------------------------------------------------------------------
    $XML = String_XML_Parse($Response);
    if (Is_Exception($XML)) {
        return ERROR | @Trigger_Error('[DNSmanager5_Password_Change]: неверный ответ от сервера');
    }
    #-------------------------------------------------------------------------------
    $XML = $XML->ToArray();
    #-------------------------------------------------------------------------------
    $Doc = $XML['doc'];
    #-------------------------------------------------------------------------------
    if (isset($Doc['error'])) {
        return new gException('PASSWORD_CHANGE_ERROR', 'Не удалось изменить пароль для заказа вторичного DNS');
    }
    #-------------------------------------------------------------------------------
    return TRUE;
    #-------------------------------------------------------------------------------
}
Ejemplo n.º 14
0
function BillManager_Check_ISPsystem_IP($Settings, $ISPswInfo)
{
    /******************************************************************************/
    $__args_types = array('array', 'array');
    #-------------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /******************************************************************************/
    $authinfo = SPrintF('%s:%s', $Settings['Login'], $Settings['Password']);
    #-------------------------------------------------------------------------------
    $HTTP = BillManager_Build_HTTP($Settings);
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    # authinfo=USER:PASSWD&out=xml&func=soft.checkip&pricelist=7&period=1&ip=82.145.17.16
    $Request = array('authinfo' => $authinfo, 'out' => 'xml', 'sok' => 'yes', 'func' => 'soft.checkip', 'pricelist' => $ISPswInfo['pricelist_id'], 'period' => $ISPswInfo['period'], 'ip' => $ISPswInfo['IP']);
    #-------------------------------------------------------------------------------
    $Response = HTTP_Send($Settings['Params']['PrefixAPI'], $HTTP, array(), $Request);
    if (Is_Error($Response)) {
        return ERROR | @Trigger_Error('[BillManager_Check_ISPsystem_IP]: не удалось соедениться с сервером');
    }
    #-----------------------------------------------------------------------------
    $Response = Trim($Response['Body']);
    $XML = String_XML_Parse($Response);
    if (Is_Exception($XML)) {
        return new gException('WRONG_SERVER_ANSWER', $Response, $XML);
    }
    #-------------------------------------------------------------------------------
    $XML = $XML->ToArray();
    #-------------------------------------------------------------------------------
    $Doc = $XML['doc'];
    if (isset($Doc['error'])) {
        return FALSE;
    }
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    return TRUE;
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
}
Ejemplo n.º 15
0
function IspManager5_Service_Restart($Settings, $Service)
{
    /******************************************************************************/
    $__args_types = array('array', 'string');
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /******************************************************************************/
    $HTTP = IspManager5_Build_HTTP($Settings);
    #-------------------------------------------------------------------------------
    $authinfo = SPrintF('%s:%s', $Settings['Login'], $Settings['Password']);
    #-------------------------------------------------------------------------------
    # достаём список сервисов
    $Response = HTTP_Send('/ispmgr', $HTTP, array(), array('authinfo' => $authinfo, 'out' => 'xml', 'func' => 'services'));
    if (Is_Error($Response)) {
        return new gException('NOT_CONNECTED_TO_SERVER', 'Не удалось соедениться с сервером');
    }
    #-------------------------------------------------------------------------------
    $Response = Trim($Response['Body']);
    #-------------------------------------------------------------------------------
    $XML = String_XML_Parse($Response);
    if (Is_Exception($XML)) {
        return new gException('WRONG_SERVER_ANSWER', $Response, $XML);
    }
    #-------------------------------------------------------------------------------
    $XML = $XML->ToArray('elem');
    #-------------------------------------------------------------------------------
    $Services = $XML['doc'];
    #-------------------------------------------------------------------------------
    if (isset($Services['error'])) {
        return new gException('GET_SERVCES_ERROR', $Services['error']);
    }
    #-------------------------------------------------------------------------------
    #Debug(SPrintF('[IspManager5_Service_Restart]: Services = %s',print_r($Services,true)));
    #-------------------------------------------------------------------------------
    # проверяем наличие такого сервиса
    foreach (Array_Keys($Services) as $ParamID) {
        if (isset($Services[$ParamID]['name'])) {
            if ($Services[$ParamID]['name'] == $Service) {
                $Exist = TRUE;
            }
        }
    }
    #-------------------------------------------------------------------------------
    # рестартуем сервис, при наличии
    if (isset($Exist)) {
        #-------------------------------------------------------------------------------
        $Request = array('authinfo' => $authinfo, 'out' => 'xml', 'func' => 'services.restart', 'elid' => $Service);
        #-------------------------------------------------------------------------------
        $Response = HTTP_Send('/ispmgr', $HTTP, array(), $Request);
        if (Is_Error($Response)) {
            return ERROR | @Trigger_Error('[IspManager5_Service_Restart]: не удалось соедениться с сервером');
        }
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    return TRUE;
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
}