function Crypt_Decode($String, $Key = HOST_ID) { /****************************************************************************/ $__args_types = array('string', 'string'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $String = Base64_Decode($String); #----------------------------------------------------------------------------- if (empty($String)) { return $String; } #----------------------------------------------------------------------------- if (Extension_Loaded('mcrypt')) { #--------------------------------------------------------------------------- $Module =& Link_Get('Crypt'); #--------------------------------------------------------------------------- if (!Is_Resource($Module)) { #------------------------------------------------------------------------- $Module = @MCrypt_Module_Open(MCRYPT_DES, '', MCRYPT_MODE_ECB, ''); if (!Is_Resource($Module)) { return ERROR | @Trigger_Error('[Crypt_Decode]: не удалось открыть дескриптор'); } #------------------------------------------------------------------------- $Iv = @MCrypt_Create_Iv(MCrypt_Enc_Get_Iv_Size($Module), MCRYPT_RAND); if (!$Iv) { return ERROR | @Trigger_Error('[Crypt_Decode]: не удалось создать IV'); } #------------------------------------------------------------------------- $Key = SubStr($Key, 0, MCrypt_Enc_Get_Key_Size($Module)); #Debug(SPrintF("[system/libs/auto/Crypt]: Decode Key = %s",$Key)); #------------------------------------------------------------------------- $IsInit = @MCrypt_Generic_Init($Module, $Key, $Iv); if (!Is_Integer($IsInit)) { return ERROR | @Trigger_Error('[Crypt_Decode]: не удалось инициализовать модуль дешифрования'); } } #--------------------------------------------------------------------------- $String = @MDecrypt_Generic($Module, $String); if (!Is_String($String)) { return ERROR | @Trigger_Error('[Crypt_Decode]: не удалось дешифровать данные'); } #--------------------------------------------------------------------------- $String = Trim($String); #--------------------------------------------------------------------------- } #----------------------------------------------------------------------------- return $String; }
function Tree_Parents($TableID, $RowID) { /****************************************************************************/ $__args_types = array('string', 'integer'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $Regulars = Regulars(); #----------------------------------------------------------------------------- if (!Preg_Match($Regulars['ID'], $TableID)) { return new gException('WRONG_TABLE_ID', 'Неверный идентификатор таблицы'); } #----------------------------------------------------------------------------- $Row = DB_Select($TableID, '*', array('UNIQ', 'ID' => $RowID)); #--------------------------------------------------------------------------- switch (ValueOf($Row)) { case 'error': return ERROR | @Trigger_Error('[Tree_Parents]: не возможно найти запись'); case 'exception': return new gException('ROW_NOT_FOUND', 'Запись не найдена'); case 'array': #------------------------------------------------------------------------- $Query = SPrintF('SELECT * FROM `%s` `TableA` WHERE `ParentID` = %u AND `ID` != `ParentID` AND EXISTS(SELECT * FROM `%s` `TableB` WHERE `TableB`.`ParentID` = `TableA`.`ID`)', $TableID, $Row['ID'], $TableID); #------------------------------------------------------------------------- $IsQuery = DB_Query($Query); if (Is_Error($IsQuery)) { return ERROR | @Trigger_Error('[Tree_Parents]: не возможно найти дочерние записи'); } #------------------------------------------------------------------------- $Childs = MySQL::Result($IsQuery); #------------------------------------------------------------------------- $Result = array($Row['ID']); #------------------------------------------------------------------------- foreach ($Childs as $Child) { #----------------------------------------------------------------------- $Parents = Tree_Parents($TableID, (int) $Child['ID']); #----------------------------------------------------------------------- switch (ValueOf($Parents)) { case 'error': return ERROR | @Trigger_Error('[Tree_Parents]: не возможно определить дочерние вхождения записей'); case 'exception': return ERROR | @Trigger_Error('[Tree_Parents]: запись оказавшаяся дочерней не найдена'); case 'array': $Result = Array_Merge($Result, $Parents); break; default: return ERROR | @Trigger_Error(101); } } #------------------------------------------------------------------------- return $Result; break; default: return ERROR | @Trigger_Error(101); } }
/** * Constructor. * * @param <type> $CodeID * @param <type> $String * @param <type> $Parent * @return <type> */ function __construct($CodeID, $String, $Parent = NULL) { $__args_types = array('string', 'string', 'NULL,object'); $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); Debug(SPrintF('[Exception]: [%s]=(%s)', $CodeID, $String)); $this->CodeID = $CodeID; $this->String = $String; $this->Parent = $Parent; return $this; }
function Comp_IsLoaded($Path) { /****************************************************************************/ $__args_types = array('string'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $Loaded =& Link_Get('Comp/Loaded', 'array'); #----------------------------------------------------------------------------- return In_Array($Path, $Loaded); }
function To_XML_String($Value, $Name = 'XML', $Level = 0) { /******************************************************************************/ $__args_types = array('array,string,integer,double,boolean,NULL', 'string,integer', 'integer'); #------------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /******************************************************************************/ $Result = SPrintF('%s<%s', $Tab = $Level ? Str_Pad("\t", $Level, "\t") : '', $Name); #------------------------------------------------------------------------------- if (Is_Array($Value)) { #------------------------------------------------------------------------------- if (Count($Value) > 0) { #------------------------------------------------------------------------------- $Result = SPrintF("%s>\n", $Result); #------------------------------------------------------------------------------- foreach (Array_Keys($Value) as $Key) { $Result = SPrintF('%s%s', $Result, To_XML_String($Value[$Key], $Key, $Level + 1)); } #------------------------------------------------------------------------------- $Result = SPrintF('%s%s', $Result, $Tab); #------------------------------------------------------------------------------- } else { #------------------------------------------------------------------------------- return SPrintF("%s type=\"array\" />\n", $Result); #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- } else { #------------------------------------------------------------------------------- $Type = GetType($Value); #------------------------------------------------------------------------------- if ($Type != 'string') { $Result = SPrintF('%s type="%s"', $Result, $Type); } #------------------------------------------------------------------------------- if (StrLen($Value) > 0) { #------------------------------------------------------------------------------- $Value = HtmlSpecialChars((string) $Value); #------------------------------------------------------------------------------- $Result = SPrintF('%s>%s', $Result, $Value); #------------------------------------------------------------------------------- } else { #------------------------------------------------------------------------------- return SPrintF("%s />\n", $Result); #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- return SPrintF("%s</%s>\n", $Result, $Name); #------------------------------------------------------------------------------- }
public function get($key) { // Check args. $__args_types = array('string'); $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); $result = apc_fetch($key); if (!$result) { Debug(SPrintF('[APCCache::get]: не удалось извлечь объект [key=%s]', $key)); } return $result; }
function get($key) { // Check args. $__args_types = array('string'); $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); $key = SPrintF('[%s]-%s', HOST_ID, $key); $result = self::$memcached->get($key); if (!$result) { Debug(SPrintF('[MemcachedCache::get]: не удалось извлечь объект [key=%s]', $key)); } return $result; }
function Color_RGB_Implode($R, $G, $B) { /****************************************************************************/ $__args_types = array('integer'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $R = SPrintF('%02X', $R); $G = SPrintF('%02X', $G); $B = SPrintF('%02X', $B); #----------------------------------------------------------------------------- return SPrintF('%s%s%s', $R, $G, $B); }
function FLAP_Explode($String) { /****************************************************************************/ $__args_types = array('string'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ if (StrLen($String) < 6) { return FALSE; } #----------------------------------------------------------------------------- return array('Chanel' => Bytes_Get($String, 01), 'Number' => Bytes_Get($String, 02, 02), 'Data' => SubStr($String, 06)); }
function Upload_Get($Name, $Hash = FALSE) { /****************************************************************************/ #$__args_types = Array('string'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $Args = Args(); #----------------------------------------------------------------------------- $Hash = isset($Args[$Name]) ? $Args[$Name] : $Hash; #----------------------------------------------------------------------------- if (!$Hash) { return new gException('HASH_IS_EMPTY', 'Хешь файла загрузки пуст'); } #----------------------------------------------------------------------------- $Tmp = System_Element('tmp'); if (Is_Error($Tmp)) { return ERROR | @Trigger_Error('[Upload_Get]: не удалось получить путь до временной директории'); } #----------------------------------------------------------------------------- $Uploads = SPrintF('%s/uploads', $Tmp); #----------------------------------------------------------------------------- if (!File_Exists($Uploads)) { return new gException('HASH_IS_EMPTY', 'Директория файлов загрузки не создана'); } #----------------------------------------------------------------------------- $Path = SPrintF('%s/%s', $Uploads, $Hash); #----------------------------------------------------------------------------- if (!File_Exists($Path)) { return new gException('FILE_NOT_FOUND', 'Файл не найден на сервере'); } #----------------------------------------------------------------------------- $Data = IO_Read($Path); if (Is_Error($Data)) { return ERROR | @Trigger_Error('[Upload_Get]: не удалось прочитать файл'); } #----------------------------------------------------------------------------- $Names = IO_Read(SPrintF('%s/names.txt', $Uploads)); if (Is_Error($Names)) { return ERROR | @Trigger_Error('[Upload_Get]: не удалось прочитать файл имен'); } #----------------------------------------------------------------------------- $Names = JSON_Decode($Names, TRUE); #----------------------------------------------------------------------------- $Name = isset($Names[$Hash]) ? $Names[$Hash] : 'Default'; #----------------------------------------------------------------------------- return array('Name' => $Name, 'Data' => $Data); }
function SNAC_Explode($String) { /****************************************************************************/ $__args_types = array('string'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $Result = array('FamilyID' => Bytes_Get($String, 00, WORD), 'SubTypeID' => Bytes_Get($String, 02, WORD), 'Flag0' => Bytes_Get($String, 05, BUTE), 'Flag1' => Bytes_Get($String, 06, BUTE), 'RequestID' => Bytes_Get($String, 04, BUTE)); #----------------------------------------------------------------------------- $Result['Data'] = SubStr($String, 11); # Сам пакет #----------------------------------------------------------------------------- return $Result; }
function TVL_Explode($String, &$Array = array()) { /****************************************************************************/ $__args_types = array('string', 'array'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $Length = HexDec(Bytes_Get($String, 02, WORD)); #----------------------------------------------------------------------------- $Array[Bytes_Get($String, 00, WORD)] = SubStr($String, 04, $Length); #----------------------------------------------------------------------------- if (StrLen($String = SubStr($String, 04 + $Length)) > 0) { TVL_Explode($String, $Array); } #----------------------------------------------------------------------------- return $Array; }
public function GetUsers() { /******************************************************************************/ $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /******************************************************************************/ Array_UnShift($__args__, $this->Settings); #------------------------------------------------------------------------------- $Function = SPrintF('%s_Get_Users', $this->SystemID); #------------------------------------------------------------------------------- if (!Function_Exists($Function)) { return new gException('FUNCTION_NOT_SUPPORTED', SPrintF('Функция (%s) не поддерживается API модулем', $Function)); } #------------------------------------------------------------------------------- $Result = Call_User_Func_Array($Function, $__args__); if (Is_Error($Result)) { return ERROR | @Trigger_Error('[ISPswServer->GetUsers]: не удалось вызвать целевую функцию'); } #------------------------------------------------------------------------------- return $Result; #------------------------------------------------------------------------------- }
function ToXMLString($Level = 0, $IsFormat = TRUE) { /****************************************************************************/ $__args_types = array('integer', 'boolean'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $Name = $this->Name; #----------------------------------------------------------------------------- $Result = SPrintF('<%s', $Name); #----------------------------------------------------------------------------- if ($IsFormat) { $Result = SPrintF('%s%s', $Level ? Str_Pad(' ', $Level) : '', $Result); } #----------------------------------------------------------------------------- $Attribs = $this->Attribs; #----------------------------------------------------------------------------- foreach (Array_Keys($Attribs) as $AttribID) { $Result .= SPrintF(' %s="%s"', $AttribID, HtmlSpecialChars((string) $Attribs[$AttribID])); } #----------------------------------------------------------------------------- $Childs = $this->Childs; #----------------------------------------------------------------------------- if (Count($Childs)) { #--------------------------------------------------------------------------- $Result .= '>'; #--------------------------------------------------------------------------- $IsNoCData = TRUE; #--------------------------------------------------------------------------- foreach ($Childs as $Child) { #------------------------------------------------------------------------- if (In_Array($Child->Name, array('CDATA'))) { #----------------------------------------------------------------------- $IsNoCData = FALSE; #----------------------------------------------------------------------- break; } } #--------------------------------------------------------------------------- $Nodes = ''; #--------------------------------------------------------------------------- foreach ($Childs as $Child) { $Nodes .= In_Array($Child->Name, array('CDATA')) ? HtmlSpecialChars($Child->Text) : $Child->ToXMLString($Level + 1, $IsNoCData); } #--------------------------------------------------------------------------- $Result .= $IsNoCData ? SPrintF("\n%s%s", $Nodes, $Level ? Str_Pad(' ', $Level) : '') : $Nodes; } else { #--------------------------------------------------------------------------- $Text = isset($Attribs['force-escape']) ? $this->Text : HtmlSpecialChars($this->Text); #--------------------------------------------------------------------------- $IsShort = !Mb_StrLen($Text) && !In_Array($Name, array('TEXTAREA', 'BUTTON', 'TITLE', 'SCRIPT', 'TABLE', 'TD', 'TR')); #--------------------------------------------------------------------------- if ($IsShort) { #------------------------------------------------------------------------- $Result .= ' />'; #------------------------------------------------------------------------- if ($IsFormat) { $Result .= "\n"; } #------------------------------------------------------------------------- return $Result; } else { $Result .= SPrintF('>%s', $Text); } } #----------------------------------------------------------------------------- $Result .= SPrintF('</%s>', $Name); #----------------------------------------------------------------------------- if ($IsFormat) { $Result .= "\n"; } #----------------------------------------------------------------------------- return $Result; }
function RuCenter_Get_Contract($Settings, $TicketID) { /****************************************************************************/ $__args_types = array('array', 'string'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ return array('ContractID' => $TicketID); }
function DB_Where($Query = array(), $Logic = 'AND') { /****************************************************************************/ $__args_types = array('array', 'string'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $Default = array('ID' => '', 'Where' => ''); #----------------------------------------------------------------------------- Array_Union($Default, $Query); #----------------------------------------------------------------------------- $Query = $Default; #----------------------------------------------------------------------------- $IDs = $Query['ID']; #----------------------------------------------------------------------------- if ($IDs) { return SPrintF('`ID` = %s', (int) $IDs); } #----------------------------------------------------------------------------- $Where = $Query['Where']; #----------------------------------------------------------------------------- if ($Where) { #--------------------------------------------------------------------------- if (!Is_Array($Where)) { $Where = array($Where); } #--------------------------------------------------------------------------- $Array = array(); #--------------------------------------------------------------------------- foreach ($Where as $Condition) { $Array[] = SPrintF('(%s)', $Condition); } #--------------------------------------------------------------------------- return Implode(SPrintF(' %s ', $Logic), $Array); } #----------------------------------------------------------------------------- return FALSE; }
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); }
function Bytes_Get($String, $Start, $Length = BUTE) { /****************************************************************************/ $__args_types = array('string', 'integer', 'integer'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $Section = SubStr($String, $Start, $Length); if (Is_String($Section)) { return Bytes_Trim(Bytes_Decode($Section)); } #----------------------------------------------------------------------------- return FALSE; }
function Styles_Menu($Path) { /****************************************************************************/ $__args_types = array('string'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $Result = $Chain = array(); #----------------------------------------------------------------------------- do { #--------------------------------------------------------------------------- $Menu = Styles_XML(SPrintF('Menus/%s.xml', $Path)); if (Is_Error($Menu)) { return ERROR | @Trigger_Error('[Styles_Menu]: не удалось загрузить файл меню'); } #--------------------------------------------------------------------------- Array_UnShift($Chain, $Menu); #--------------------------------------------------------------------------- $Path = isset($Menu['RootID']) ? $Menu['RootID'] : FALSE; #--------------------------------------------------------------------------- } while ($Path); #----------------------------------------------------------------------------- foreach ($Chain as $Menu) { Array_Union($Result, $Menu); } #----------------------------------------------------------------------------- $Items =& $Result['Items']; #----------------------------------------------------------------------------- if (isset($Result['Comp'])) { #--------------------------------------------------------------------------- $Comp = Comp_Load($Result['Comp']); if (Is_Error($Comp)) { return ERROR | @Trigger_Error(500); } #--------------------------------------------------------------------------- if (Is_Array($Comp)) { Array_Union($Items, $Comp); } } #----------------------------------------------------------------------------- foreach (Array_Keys($Items) as $ItemID) { #--------------------------------------------------------------------------- $Item =& $Items[$ItemID]; #--------------------------------------------------------------------------- if (!Is_Array($Item)) { continue; } #--------------------------------------------------------------------------- if (isset($Item['UnActive'])) { unset($Items[$ItemID]); } #--------------------------------------------------------------------------- $IsActive = FALSE; #--------------------------------------------------------------------------- foreach ($Item['Paths'] as $Path) { #------------------------------------------------------------------------- $IsActive = Preg_Match(SPrintF('/%s/', $Path), $GLOBALS['__URI']) || Preg_Match(SPrintF('/%s/', $Path), $_SERVER['REQUEST_URI']); #------------------------------------------------------------------------- if ($IsActive) { break; } } #--------------------------------------------------------------------------- $Item['IsActive'] = $IsActive; } #----------------------------------------------------------------------------- KSort($Items); #----------------------------------------------------------------------------- return $Result; }
function LogicBoxes_Check_Task($Settings, $TicketID) { /****************************************************************************/ $__args_types = array('array', 'string'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ return array('DomainID' => 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; } }
function IspManager4_Build_HTTP($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']); #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- return $HTTP; #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- }
function Array_ToLine($Array, $Border = '', $Path = '', &$Result = array()) { /****************************************************************************/ $__args_types = array('array', 'string', 'string', 'array'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ foreach (Array_Keys($Array) as $Key) { #--------------------------------------------------------------------------- $Name = $Path ? SPrintF('%s.%s', $Path, $Key) : $Key; #--------------------------------------------------------------------------- if (Is_Array($Child = $Array[$Key])) { #------------------------------------------------------------------------- if (Is_Error(Array_ToLine($Child, $Border, $Name, $Result))) { return ERROR | Trigger_Error('[Array_ToLine]: ошибка рекурсивного вызова'); } } else { #------------------------------------------------------------------------- $Result[$Border . $Name . $Border] = $Child; } } #----------------------------------------------------------------------------- return $Result; }
function R01_Check_Task($Settings, $TicketID) { /****************************************************************************/ $__args_types = array('array', 'string'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $CheckTask = new SoapClient(null, array('location' => SPrintF('https://%s:%d/%s', $Settings['Address'], $Settings['Port'], $Settings['Params']['PrefixAPI']), 'uri' => 'urn:RegbaseSoapInterface', 'exceptions' => 1, 'user_agent' => 'RegbaseSoapInterfaceClient', 'trace' => 1)); #----------------------------------------------------------------------------- if (Is_SOAP_Fault($CheckTask)) { #--------------------------------------------------------------------------- $Msg = SPrintF('Ошибка обращения к регистратору: %s', $CheckTask->faultstring); #--------------------------------------------------------------------------- return new gException('REQUEST_ERROR', $Msg); } #----------------------------------------------------------------------------- $loginResult = $CheckTask->logIn($Settings['Login'], $Settings['Password']); #----------------------------------------------------------------------------- if (Is_SOAP_Fault($loginResult)) { #--------------------------------------------------------------------------- $Msg = SPrintF('Ошибка при авторизации: %s', $loginResult->faultstring); #--------------------------------------------------------------------------- return new gException('REQUEST_ERROR', $Msg); } #----------------------------------------------------------------------------- if ($loginResult->status->code == '0') { #--------------------------------------------------------------------------- $Msg = SPrintF('Ошибка авторизации [name=%s, message=%s]', $loginResult->status->name, $loginResult->status->message); #--------------------------------------------------------------------------- return new gException('AUTHORIZATION_FAILED', $Msg); } #----------------------------------------------------------------------------- $CheckTask->__setCookie('SOAPClient', $loginResult->status->message); #----------------------------------------------------------------------------- $Response = $CheckTask->checkTask($TicketID); #----------------------------------------------------------------------------- //Debug(Print_R($Response, TRUE)); #----------------------------------------------------------------------------- if (Is_SOAP_Fault($Response)) { #--------------------------------------------------------------------------- $Msg = SPrintF('Ошибка при выполнении запроса: %s', $Response->faultstring); #--------------------------------------------------------------------------- return new gException('REQUEST_ERROR', $Msg); } #----------------------------------------------------------------------------- if ($Response->status->code == '0') { #--------------------------------------------------------------------------- $Msg = SPrintF('Ошибка проверки статуса задачи [name=%s, message=%s]', $Response->status->name, $Response->status->message); #--------------------------------------------------------------------------- return new gException('TASK_FAILED', $Msg); } #----------------------------------------------------------------------------- switch ($Response->status->name) { case 'TASK_SUCCESS': return array('DomainID' => 0); case 'TASK_FAILURE': #------------------------------------------------------------------------- $Msg = SPrintF('Ошибка при выполнения задачи [name=%s, message=%s]', $Response->status->name, $Response->status->message); #------------------------------------------------------------------------- return new gException('TASK_FAILURE', $Msg); case 'TASK_QUEUED': return FALSE; default: return new gException('WRONG_STATUS', 'Неизвестный статус задачи.'); } #----------------------------------------------------------------------------- $logoutResult = $CheckTask->logOut(); #----------------------------------------------------------------------------- if (Is_SOAP_Fault($logoutResult)) { #--------------------------------------------------------------------------- $Msg = SPrintF('Ошибка закрытия сессии: %s', $logoutResult->faultstring); #--------------------------------------------------------------------------- return new gException('REQUEST_ERROR', $Msg); } #----------------------------------------------------------------------------- return new gException('WRONG_CASE', ''); }
function LoadComp($__FILE__) { #------------------------------------------------------------------------------- $__args__ = Array_Slice(Func_Get_Args(), 2); #------------------------------------------------------------------------------- Debug(SPrintF("Load file: '%s'", $__FILE__)); #------------------------------------------------------------------------------- $GLOBALS['__COUNTER_COMPS']++; #------------------------------------------------------------------------------- # get file $FileContent = File($__FILE__); #------------------------------------------------------------------------------- # delete last string unset($FileContent[SizeOf($FileContent) - 1]); #------------------------------------------------------------------------------- # delete first string unset($FileContent[0]); #------------------------------------------------------------------------------- # create text from array $FileContent = Implode("\n", $FileContent); #------------------------------------------------------------------------------- # get result $CompResult = eval($FileContent); /*if($CompResult === FALSE) { Debug($__FILE__); return ERROR | @Trigger_Error(1000); }*/ #------------------------------------------------------------------------------- return $CompResult; #------------------------------------------------------------------------------- }
function HTMLDoc_CreatePDF($ModeID, $HTML, $Prefix = '/') { /****************************************************************************/ $__args_types = array('string', 'string,object', 'string'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ if (Is_Object($HTML)) { #--------------------------------------------------------------------------- $Tables = $HTML->GetByTagName('TABLE'); #--------------------------------------------------------------------------- for ($i = 0; $i < Count($Tables); $i++) { #------------------------------------------------------------------------- $Table =& $Tables[$i]; #------------------------------------------------------------------------- switch (@$Table->Attribs['class']) { case 'Standard': $Table->AddAttribs(array('border' => 2, 'cellspacing' => 0, 'cellpadding' => 5), TRUE); break; default: # No more... } } #--------------------------------------------------------------------------- $Tds = $HTML->GetByTagName('TD'); #--------------------------------------------------------------------------- for ($i = 0; $i < Count($Tds); $i++) { #------------------------------------------------------------------------- $Td =& $Tds[$i]; #------------------------------------------------------------------------- switch (@$Td->Attribs['class']) { case 'Head': $Td->AddAttribs(array('bgcolor' => '#ADC1F0'), TRUE); break; case 'Separator': $Td->AddAttribs(array('bgcolor' => '#EAEAEA'), TRUE); break; default: # No more... } } #--------------------------------------------------------------------------- $Imgs = $HTML->GetByTagName('IMG'); #--------------------------------------------------------------------------- for ($i = 0; $i < Count($Imgs); $i++) { #------------------------------------------------------------------------- $Img =& $Imgs[$i]; #------------------------------------------------------------------------- $Img->AddAttribs(array('src' => SPrintF('%s/%s', $Prefix, $Img->Attribs['src'])), TRUE); } #--------------------------------------------------------------------------- $HTML = $HTML->Build(); } #----------------------------------------------------------------------------- $Config = Config(); #----------------------------------------------------------------------------- $Settings = $Config['HTMLDOC']; #----------------------------------------------------------------------------- $Modes = $Settings['Modes']; #----------------------------------------------------------------------------- $Mode = isset($Modes[$ModeID]) ? $Modes[$ModeID] : $ModeID; #----------------------------------------------------------------------------- $Tmp = System_Element('tmp'); if (Is_Error($Tmp)) { return ERROR | @Trigger_Error('[HTMLDoc_CreatePDF]: временная папка не найдена'); } #----------------------------------------------------------------------------- $Logs = SPrintF('%s/logs', $Tmp); #----------------------------------------------------------------------------- if (!File_Exists($Logs)) { #--------------------------------------------------------------------------- if (!@MkDir($Logs, 0777, TRUE)) { return ERROR | @Trigger_Error(500); } } #----------------------------------------------------------------------------- $HTML = @Mb_Convert_Encoding($HTML, $Settings['ConvertToCharset']); if (!$HTML) { return ERROR | @Trigger_Error('[HTMLDoc_CreatePDF]: не удалось преобразовать кодировку'); } #----------------------------------------------------------------------------- $UniqID = UniqID('HTMLDOC'); #----------------------------------------------------------------------------- $File = IO_Write($Path = SPrintF('%s/%s', $Tmp, $UniqID), $HTML); Debug($File); if (Is_Error($File)) { return ERROR | @Trigger_Error('[HTMLDoc_CreatePDF]: не удалось создать временный файл'); } #----------------------------------------------------------------------------- $Command = SPrintF('htmldoc %s %s', $Mode, $Path); #----------------------------------------------------------------------------- Debug($Command); #----------------------------------------------------------------------------- if (!PutENV('HTMLDOC_NOCGI=1')) { return ERROR | @Trigger_Error('[HTMLDoc_CreatePDF]: не удалось установить переменную окружения HTMLDOC_NOCGI'); } #----------------------------------------------------------------------------- $HTMLDOC = @Proc_Open($Command, array(array('pipe', 'r'), array('pipe', 'w'), array('file', $Log = SPrintF('%s/HTMLDOC.log', $Logs), 'a')), $Pipes); if (!Is_Resource($HTMLDOC)) { return ERROR | @Trigger_Error('[HTMLDoc_CreatePDF]: не удалось открыть процесс'); } #----------------------------------------------------------------------------- $StdOut =& $Pipes[1]; #----------------------------------------------------------------------------- $Result = ''; #----------------------------------------------------------------------------- while (!Feof($StdOut)) { $Result .= FRead($StdOut, 1024); } #----------------------------------------------------------------------------- Proc_Close($HTMLDOC); #----------------------------------------------------------------------------- if (!UnLink($Path)) { return ERROR | @Trigger_Error('[HTMLDoc_CreatePDF]: не удалось удалить временный файл'); } #----------------------------------------------------------------------------- if (!$Result) { return ERROR | @Trigger_Error(SPrintF('[HTMLDoc_CreatePDF]: ошибка формирования PDF, смотрите (%s)', $Log)); } #----------------------------------------------------------------------------- return $Result; }
function MasterName_Get_Contract($Settings, $TicketID) { /****************************************************************************/ $__args_types = array('array', 'string'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $HTTP = array('Address' => $Settings['Address'], 'Port' => $Settings['Port'], 'Host' => $Settings['Address'], 'Protocol' => $Settings['Protocol'], 'Charset' => 'CP1251', 'IsLogging' => $Settings['Params']['IsLogging']); #----------------------------------------------------------------------------- $Query = array(); #----------------------------------------------------------------------------- $Query[] = '[request]'; $Query[] = SPrintF('login: %s', $Settings['Login']); $Query[] = SPrintF('password: %s', $Settings['Password']); $Query[] = 'action: request_status'; $Query[] = SPrintF('request-id: %s', $TicketID); #----------------------------------------------------------------------------- $Query = array('request' => Implode("\n", $Query)); #----------------------------------------------------------------------------- $Result = HTTP_Send('/partner_gateway', $HTTP, array(), $Query); if (Is_Error($Result)) { return ERROR | @Trigger_Error('[MasterName_Check_Task]:не удалось выполнить запрос к серверу'); } #----------------------------------------------------------------------------- $Result = Trim($Result['Body']); #----------------------------------------------------------------------------- if (Preg_Match('/status:\\s([0-9]+)\\s/', $Result, $CodeID)) { #--------------------------------------------------------------------------- $CodeID = Next($CodeID); #--------------------------------------------------------------------------- switch ($CodeID) { case '200': return FALSE; case '201': return FALSE; case '202': #----------------------------------------------------------------------- if (Preg_Match('/client:\\s([0-9]+\\/[A-Z\\-]+)\\n/', $Result, $Contract)) { return array('ContractID' => Next($Contract)); } #----------------------------------------------------------------------- return new gException('REQUEST_FAILED', 'Не удалось определить клиентский номер договора'); case '203': return new gException('REQUEST_FAILED', 'Обработка запроса завершилась с ошибкой'); case '400': return new gException('BAD_REQUEST', 'Неверный формат запроса'); case '401': return new gException('AUTH_ERROR', 'Ошибка авторизации'); case '402': return new gException('DATA_ERROR', 'Ошибка в данных запроса'); case '403': return new gException('FORBIDDEN', 'Доступ к запрашиваемому объекту запрещен'); case '404': return new gException('NOT_FOUND', 'Запрашиваемый объект не найден'); case '405': return new gException('INVALID_REQUEST', 'Невозможно выполнить запрос'); case '500': return new gException('SERVER_ERROR', 'Внутренняя ошибка сервера'); default: return new gException('WRONG_ERROR', 'Неизвестный статус ошибки'); } } #----------------------------------------------------------------------------- return new gException('WRONG_ANSWER', $Result); }
public function SelectDB() { /******************************************************************************/ $__args_types = array('string'); #------------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /******************************************************************************/ if (!Is_Resource($this->Link)) { return ERROR | @Trigger_Error('[MySQL->SelectDB]: нет соединения с MySQL'); } #------------------------------------------------------------------------------- $DbName = $this->Settings['DbName']; #------------------------------------------------------------------------------- $SqlResult = $this->Query(SPrintF('USE `%s`', $DbName)); if (Is_Error($SqlResult)) { return ERROR | @Trigger_Error(SPrintF('[MySQL->SelectDB]: невозможно выбрать базу данных (%s)', $DbName)); } #------------------------------------------------------------------------------- return TRUE; #------------------------------------------------------------------------------- }
/** * Удаляет объект из списка объектов * * Функция удаляет объект из массива ссылок на объкты по идентификатору $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(); }
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', 'Неизвестный ответ'); } }