Beispiel #1
1
function HTTP_Send($Target, $Settings, $Get = array(), $Post = array(), $Addins = array())
{
    /******************************************************************************/
    $__args_types = array('string', 'array', 'array', 'string,array', 'array');
    #-------------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /******************************************************************************/
    $Default = array('Protocol' => 'tcp', 'Address' => 'localhost', 'Port' => 8080, 'Host' => 'localhost', 'Basic' => '', 'Charset' => 'UTF-8', 'Hidden' => '', 'IsLogging' => TRUE);
    #-------------------------------------------------------------------------------
    Array_Union($Default, $Settings);
    #-------------------------------------------------------------------------------
    $IsLogging = (bool) $Default['IsLogging'];
    #-------------------------------------------------------------------------------
    $Tmp = System_Element('tmp');
    if (Is_Error($Tmp)) {
        return ERROR | @Trigger_Error('[HTTP_Send]: не удалось определить путь временной директории');
    }
    #-------------------------------------------------------------------------------
    $Config = Config();
    #-------------------------------------------------------------------------------
    $Address = $Default['Address'];
    #-------------------------------------------------------------------------------
    Debug(SPrintF('[HTTP_Send]: соединяемся с (%s:%u)', $Address, $Default['Port']));
    #-------------------------------------------------------------------------------
    # https://bugs.php.net/bug.php?id=52913
    # пришлось заменить: $Address -> $Default['Host']
    $Socket = @FsockOpen(SPrintF('%s://%s', $Protocol = $Default['Protocol'], $Default['Host']), $Port = $Default['Port'], $nError, $sError, $Config['Other']['Libs']['HTTP']['SocketTimeout']);
    if (!Is_Resource($Socket)) {
        #-------------------------------------------------------------------------------
        $IsWrite = IO_Write(SPrintF('%s/logs/http-send.log', $Tmp), SPrintF("%s://%s:%u ошибка соединения\n\n", $Protocol, $Address, $Port));
        if (Is_Error($IsWrite)) {
            return ERROR | @Trigger_Error('[HTTP_Send]: не удалось записать данные в лог файл');
        }
        #-------------------------------------------------------------------------------
        return ERROR | @Trigger_Error('[HTTP_Send]: не удалось соединиться с удаленным хостом');
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
    # added by lissyara, 2012-01-04 in 08:42:54 MSK, for JBS-130
    Stream_Set_TimeOut($Socket, $Config['Other']['Libs']['HTTP']['StreamTimeout']);
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    $Charset = $Default['Charset'];
    #-------------------------------------------------------------------------------
    $Method = Count($Post) > 0 ? 'POST' : 'GET';
    #-------------------------------------------------------------------------------
    $Hidden = $Default['Hidden'];
    #-------------------------------------------------------------------------------
    if (Count($Get)) {
        $Target .= SPrintF('?%s', HTTP_Query($Get, $Charset, $Hidden, $IsLogging));
    }
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    $Headers[] = SPrintF('%s %s HTTP/1.0', $Method, $Target);
    #-------------------------------------------------------------------------------
    $Headers[] = SPrintF('Host: %s', $Default['Host']);
    #-------------------------------------------------------------------------------
    $Headers[] = 'Connection: close';
    #-------------------------------------------------------------------------------
    $Headers = Array_Merge($Headers, $Addins);
    #-------------------------------------------------------------------------------
    if ($Basic = $Default['Basic']) {
        #-------------------------------------------------------------------------------
        $Basic = Base64_Encode($Basic);
        #-------------------------------------------------------------------------------
        $Headers[] = SPrintF('Authorization: Basic %s', $Basic);
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
    $Body = '';
    #-------------------------------------------------------------------------------
    if ($Post) {
        #-------------------------------------------------------------------------------
        if (Is_Array($Post)) {
            #-------------------------------------------------------------------------------
            if (Count($Post) > 0) {
                #-------------------------------------------------------------------------------
                $Headers[] = 'Content-Type: application/x-www-form-urlencoded';
                #-------------------------------------------------------------------------------
                $Body = HTTP_Query($Post, $Charset, $Hidden, $IsLogging);
                #-------------------------------------------------------------------------------
            }
            #-------------------------------------------------------------------------------
        } else {
            #-------------------------------------------------------------------------------
            $Body = Mb_Convert_Encoding($Post, $Charset);
            #-------------------------------------------------------------------------------
        }
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
    if ($Length = MB_StrLen($Body, 'ASCII')) {
        $Headers[] = SPrintF('Content-Length: %u', $Length);
    }
    #-------------------------------------------------------------------------------
    $Query = SPrintF("%s\r\n\r\n%s", Implode("\r\n", $Headers), $Body);
    #-------------------------------------------------------------------------------
    Debug(SPrintF("[HTTP_Send]: делаем запрос:\n%s", $Query));
    #-------------------------------------------------------------------------------
    if (!@Fwrite($Socket, $Query)) {
        return ERROR | @Trigger_Error('[HTTP_Send]: не удалось записать в сокет');
    }
    #-------------------------------------------------------------------------------
    # added by lissyara, 2014-01-28 in 14:19:08 MSK, for JBS-130
    Stream_Set_TimeOut($Socket, $Config['Other']['Libs']['HTTP']['StreamTimeout']);
    #-------------------------------------------------------------------------------
    $Receive = '';
    #-------------------------------------------------------------------------------
    do {
        #-------------------------------------------------------------------------------
        $Bytes = @FGets($Socket);
        #-------------------------------------------------------------------------------
        $Receive .= $Bytes;
        #-------------------------------------------------------------------------------
    } while ($Bytes);
    #-------------------------------------------------------------------------------
    @Fclose($Socket);
    #-------------------------------------------------------------------------------
    if (Preg_Match('/Content-Type:[\\sa-zA-Z0-9\\/\\-\\;]+charset\\=([a-zA-Z0-9\\-]+)/i', $Receive, $Matches)) {
        #-------------------------------------------------------------------------------
        $Receive = Mb_Convert_Encoding($Receive, 'UTF-8', Next($Matches));
        #-------------------------------------------------------------------------------
    } else {
        #-------------------------------------------------------------------------------
        $Receive = Mb_Convert_Encoding($Receive, 'UTF-8', $Default['Charset']);
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
    Debug(SPrintF("[HTTP_Send]: получили ответ:\n%s", $Receive));
    #-------------------------------------------------------------------------------
    $Log = SPrintF("%s://%s:%u [%s]\n%s\n%s\n\n", $Protocol, $Address, $Port, Date('r'), $Query, $Receive);
    #-------------------------------------------------------------------------------
    if ($Hidden) {
        #-------------------------------------------------------------------------------
        if (!Is_Array($Hidden)) {
            $Hidden = array($Hidden);
        }
        #-------------------------------------------------------------------------------
        foreach ($Hidden as $Pattern) {
            #-------------------------------------------------------------------------------
            $Pattern = UrlEncode(Mb_Convert_Encoding($Pattern, $Charset));
            #-------------------------------------------------------------------------------
            $Log = Str_Replace($Pattern, SPrintF('[HIDDEN=(%u)]', StrLen($Pattern)), $Log);
            #-------------------------------------------------------------------------------
        }
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
    if ($Default['IsLogging']) {
        #-------------------------------------------------------------------------------
        $IsWrite = IO_Write(SPrintF('%s/logs/http-send.log', $Tmp), $Log);
        if (Is_Error($IsWrite)) {
            return ERROR | @Trigger_Error('[HTTP_Send]: не удалось записать данные в лог файл');
        }
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    $Heads = $Body = array();
    #-------------------------------------------------------------------------------
    foreach (Explode("\r\n\r\n", $Receive) as $Chunk) {
        #-------------------------------------------------------------------------------
        if (Preg_Match('#^HTTP/1\\.*#', $Chunk)) {
            #-------------------------------------------------------------------------------
            $Heads[] = $Chunk;
            #-------------------------------------------------------------------------------
        } else {
            #-------------------------------------------------------------------------------
            $Body[] = $Chunk;
            #-------------------------------------------------------------------------------
        }
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
    if (SizeOf($Body) < 1) {
        return ERROR | @Trigger_Error('[HTTP_Send]: ответ от сервера не верен');
    }
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    return array('Heads' => Implode("\r\n\r\n", $Heads), 'Body' => Implode("\r\n\r\n", $Body));
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    #$Receive = Preg_Split('/\r\n\r\n/',$Receive,PREG_SPLIT_DELIM_CAPTURE);
    #-------------------------------------------------------------------------------
    #if(Count($Receive) < 2)
    #	return ERROR | @Trigger_Error('[HTTP_Send]: ответ от сервера не верен');
    #-------------------------------------------------------------------------------
    #$Receive = Array_Combine(Array('Heads','Body'),$Receive);
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    #return $Receive;
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
}
Beispiel #2
0
function Array_Union(&$What, $Whom, $IsReplace = TRUE)
{
    /****************************************************************************/
    $__args_types = array('array', 'array', 'array');
    #-----------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    //Die(FUNCTION_INIT);
    eval(FUNCTION_INIT);
    //echo Base64_Decode('JF9fYXJnc19fID0gRnVuY19HZXRfQXJncygpOw0KaWYoSXNTZXQoJF9fYXJnc190eXBlcykpew0KICBmb3IoJGk9MDskaTxDb3VudCgkX19hcmdzX18pOyRpKyspew0KICAgICRfX2FyZ190eXBlID0gKCRpIDwgQ291bnQoJF9fYXJnc190eXBlcyk/JF9fYXJnc190eXBlc1skaV06JF9fYXJnc190eXBlc1tDb3VudCgkX19hcmdzX3R5cGVzKS0xXSk7DQogICAgaWYoJF9fYXJnX3R5cGUgPT0gJyonKQ0KICAgICAgY29udGludWU7DQogICAgJF9fdHlwZSA9IEdldFR5cGUoJF9fYXJnc19fWyRpXSk7DQogICAgaWYoIUluX0FycmF5KCRfX3R5cGUsRXhwbG9kZSgnLCcsJF9fYXJnX3R5cGUpKSl7DQogICAgICBEZWJ1ZyhQcmludF9SKCRfX2FyZ3NfXyxUUlVFKSk7DQogICAgICBUcmlnZ2VyX0Vycm9yKFNQcmludEYoJ1tGVU5DVElPTl9JTklUXTog0L/QsNGA0LDQvNC10YLRgCAoJXMpINC/0YDQuNC90Y/RgiAoJXMpINC+0LbQuNC00LDQu9GB0Y8gKCVzKScsJGksJF9fdHlwZSwkX19hcmdfdHlwZSkpOw0KICAgIH0NCiAgfQ0KfQ==');
    //echo Base64_Decode('aWYoSXNTZXQoJF9fYXJnc190eXBlcykpeyBmb3IoJGk9MDskaTwgQ291bnQoJF9fYXJnc190eXBlcyk/JF9fYXJnc190eXBlc1skaV06JF9fYXJnc190eXBlc1tDb3VudCgkX19hcmdzX3R5cGVzKS0xXSk7IGlmKCRfX2FyZ190eXBlID09ICcqJykgY29udGludWU7ICRfX3R5cGUgPSBHZXRUeXBlKCRfX2FyZ3NfX1skaV0pOyBpZighSW5fQXJyYXkoJF9fdHlwZSxFeHBsb2RlKCcsJywkX19hcmdfdHlwZSkpKXsgRGVidWcoUHJpbnRfUigkX19hcmdzX18sVFJVRSkpOyBUcmlnZ2VyX0Vycm9yKFNQcmludEYoJ1tGVU5DVElPTl9JTklUXTog0L/QsNGA0LDQvNC10YLRgCAoJXMpINC/0YDQuNC90Y/RgiAoJXMpINC+0LbQuNC00LDQu9GB0Y8gKCVzKScsJGksJF9fdHlwZSwkX19hcmdfdHlwZSkpOyB9IH0gfQ==');
    //Die();
    /****************************************************************************/
    foreach (Array_Keys($Whom) as $Key) {
        #---------------------------------------------------------------------------
        if (!isset($What[$Key])) {
            $What[$Key] = $Whom[$Key];
        } else {
            #-------------------------------------------------------------------------
            $Element1 =& $What[$Key];
            $Element2 =& $Whom[$Key];
            #-------------------------------------------------------------------------
            if (Is_Array($Element1) && Is_Array($Element2)) {
                Array_Union($Element1, $Element2);
            } else {
                #-----------------------------------------------------------------------
                if ($IsReplace) {
                    $What[$Key] = $Whom[$Key];
                }
            }
        }
    }
}
Beispiel #3
0
 function __construct($Settings = array())
 {
     #-------------------------------------------------------------------------------
     $this->Settings = array('Server' => 'localhost', 'Port' => 3306, 'User' => 'root', 'Password' => '*', 'DbName' => 'UnSelected');
     #-------------------------------------------------------------------------------
     Array_Union($this->Settings, $Settings);
     #-------------------------------------------------------------------------------
 }
Beispiel #4
0
function &Args()
{
    #-----------------------------------------------------------------------------
    $Name = Md5('Args');
    #-----------------------------------------------------------------------------
    if (!isset($GLOBALS[$Name])) {
        #---------------------------------------------------------------------------
        $GLOBALS[$Name] = $_GET;
        #---------------------------------------------------------------------------
        Array_Union($GLOBALS[$Name], $_POST);
    }
    #-----------------------------------------------------------------------------
    return $GLOBALS[$Name];
}
Beispiel #5
0
function DirectAdmin_Create($Settings, $Login, $Password, $Domain, $IP, $HostingScheme, $Email, $PersonID = 'Default', $Person = array())
{
    /****************************************************************************/
    $__args_types = array('array', 'string', 'string', 'string', 'string', 'array', 'string', 'string', 'array');
    #-----------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /****************************************************************************/
    $HTTP = array('Address' => $Settings['IP'], 'Port' => $Settings['Port'], 'Host' => $Settings['Address'], 'Protocol' => $Settings['Protocol'], 'Basic' => SPrintF('%s:%s', $Settings['Login'], $Settings['Password']), 'IsLogging' => $Settings['Params']['IsLogging']);
    #-----------------------------------------------------------------------------
    $IsReselling = $HostingScheme['IsReselling'];
    #-----------------------------------------------------------------------------
    $IDNA = new Net_IDNA_php5();
    $Domain = $IDNA->encode($Domain);
    #-----------------------------------------------------------------------------
    $Request = array('action' => 'create', 'add' => 'Submit', 'username' => $Login, 'passwd' => $Password, 'passwd2' => $Password, 'domain' => $Domain, 'ip' => $IP, 'notify' => 'NO', 'email' => $Email);
    #-----------------------------------------------------------------------------
    $PackageID = $HostingScheme['PackageID'];
    #-----------------------------------------------------------------------------
    if ($PackageID) {
        $Request['package'] = $PackageID;
    } else {
        #---------------------------------------------------------------------------
        $Adding = array('bandwidth' => $HostingScheme['QuotaTraffic'], 'ubandwidth' => $HostingScheme['QuotaTraffic'] != -1 ? 'OFF' : 'ON', 'quota' => $HostingScheme['QuotaDisk'], 'uquota' => $HostingScheme['QuotaDisk'] != -1 ? 'OFF' : 'ON', 'vdomains' => $HostingScheme['QuotaDomains'], 'uvdomains' => $HostingScheme['QuotaDomains'] != -1 ? 'OFF' : 'ON', 'nsubdomains' => $HostingScheme['QuotaSubDomains'], 'unsubdomains' => $HostingScheme['QuotaSubDomains'] != -1 ? 'OFF' : 'ON', 'nemails' => $HostingScheme['QuotaEmail'], 'unemails' => $HostingScheme['QuotaEmail'] != -1 ? 'OFF' : 'ON', 'nemailf' => $HostingScheme['QuotaEmailForwards'], 'unemailf' => $HostingScheme['QuotaEmailForwards'] != -1 ? 'OFF' : 'ON', 'nemailml' => $HostingScheme['QuotaEmailLists'], 'unemailml' => $HostingScheme['QuotaEmailLists'] != -1 ? 'OFF' : 'ON', 'nemailr' => $HostingScheme['QuotaEmailAutoResp'], 'unemailr' => $HostingScheme['QuotaEmailAutoResp'] != -1 ? 'OFF' : 'ON', 'mysql' => $HostingScheme['QuotaDBs'], 'umysql' => $HostingScheme['QuotaDBs'] != -1 ? 'OFF' : 'ON', 'domainptr' => $HostingScheme['QuotaParkDomains'], 'udomainptr' => $HostingScheme['QuotaParkDomains'] != -1 ? 'OFF' : 'ON', 'ftp' => $HostingScheme['QuotaFTP'], 'uftp' => $HostingScheme['QuotaFTP'] != -1 ? 'OFF' : 'ON', 'aftp' => $HostingScheme['IsAnonimousFTP'] ? 'ON' : 'OFF', 'ssh' => $HostingScheme['IsShellAccess'] ? 'ON' : 'OFF', 'ssl' => $HostingScheme['IsSSLAccess'] ? 'ON' : 'OFF', 'cgi' => $HostingScheme['IsCGIAccess'] ? 'ON' : 'OFF', 'php' => $HostingScheme['IsPHPAccess'] ? 'ON' : 'OFF', 'spamd' => $HostingScheme['IsSpamAssasing'] ? 'ON' : 'OFF', 'catchall' => $HostingScheme['IsCatchAll'] ? 'ON' : 'OFF', 'sysinfo' => $HostingScheme['IsSystemInfo'] ? 'ON' : 'OFF', 'dnscontrol' => $HostingScheme['IsDnsControll'] ? 'ON' : 'OFF');
        #---------------------------------------------------------------------------
        Array_Union($Request, $Adding);
    }
    #-----------------------------------------------------------------------------
    $Response = HTTP_Send($IsReselling ? '/CMD_API_ACCOUNT_RESELLER' : '/CMD_API_ACCOUNT_USER', $HTTP, $Request);
    if (Is_Error($Response)) {
        return ERROR | @Trigger_Error('[DirectAdmin_Create]: не удалось осуществить запрос');
    }
    #-----------------------------------------------------------------------------
    $Result = Trim($Response['Body']);
    #-----------------------------------------------------------------------------
    if (Preg_Match('/User\\screated\\ssuccessfully/', $Result)) {
        return TRUE;
    }
    #-----------------------------------------------------------------------------
    return new gException('WRONG_ANSWER', $Result);
}
Beispiel #6
0
     Debug(SPrintF('[comp/Triggers/GLOBAL]: цена на услугу больше нуля (%s), заказ не производится', $CostPay));
     #-------------------------------------------------------------------------------
     continue;
     #-------------------------------------------------------------------------------
 } else {
     #-------------------------------------------------------------------------------
     Debug(SPrintF('[comp/Triggers/GLOBAL]: цена на услугу ноль (%s) или IsZeroPriceOrder = FALSE', $CostPay));
     #-------------------------------------------------------------------------------
 }
 #-------------------------------------------------------------------------------
 #-------------------------------------------------------------------------------
 $Array = array('ContractID' => $Order['Row']['ContractID'], SPrintF('%sSchemeID', $Service['Code']) => $SchemeID, 'Comment' => SPrintF('Автоматическое создание услуги, группа серверов #%u, "%s"', $ServersGroup['ID'], $ServersGroup['Name']));
 #-------------------------------------------------------------------------------
 # реализация JBS-937
 if (Is_Array($AdditionalParams)) {
     Array_Union($Array, $AdditionalParams);
 }
 #-------------------------------------------------------------------------------
 #-------------------------------------------------------------------------------
 $OrderID = SPrintF('%sOrderID', $Service['Code']);
 #-------------------------------------------------------------------------------
 # заказываем услугу
 if (!isset($ExistsOrderID)) {
     #-------------------------------------------------------------------------------
     $Path = SPrintF('www/API/%sOrder', $Service['Code']);
     #-------------------------------------------------------------------------------
     if (Is_Error(System_Element(SPrintF('comp/%s.comp.php', $Path)))) {
         #-------------------------------------------------------------------------------
         Debug(SPrintF('[comp/Triggers/GLOBAL]: API для заказа сервиса не найдено: %s', $Path));
         #-------------------------------------------------------------------------------
         continue;
Beispiel #7
0
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;
}
Beispiel #8
0
$ConfigNames = array();
#-------------------------------------------------------------------------------
$HostsIDs = $GLOBALS['HOST_CONF']['HostsIDs'];
#-------------------------------------------------------------------------------
foreach (Array_Reverse($HostsIDs) as $HostID) {
    #-----------------------------------------------------------------------------
    $Path = SPrintF('%s/hosts/%s/config/Config.ini', SYSTEM_PATH, $HostID);
    #-----------------------------------------------------------------------------
    if (File_Exists($Path)) {
        #---------------------------------------------------------------------------
        $Adding = Parse_Ini_File($Path);
        if (!$Adding) {
            return ERROR | Trigger_Error(500);
        }
        #---------------------------------------------------------------------------
        Array_Union($ConfigNames, $Adding);
    }
}
#-------------------------------------------------------------------------------
$Links['ConfigNames'] =& $ConfigNames;
#-------------------------------------------------------------------------------
$Config = Config();
#-------------------------------------------------------------------------------
$Location = $Location ? Explode('-', $Location) : array();
#-------------------------------------------------------------------------------
foreach ($Location as $Name) {
    $Config = $Config[$Name];
}
#-------------------------------------------------------------------------------
$Into = Config_Read($Config, $Location);
#-------------------------------------------------------------------------------
Beispiel #9
0
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;
}
Beispiel #10
0
<?php

#-------------------------------------------------------------------------------
/** @author Великодный В.В. (Joonte Ltd.) */
/******************************************************************************/
/******************************************************************************/
$__args_list = array('Attribs');
/******************************************************************************/
eval(COMP_INIT);
/******************************************************************************/
/******************************************************************************/
$Default = array('name' => 'Summ', 'size' => 6, 'style' => 'text-align:right', 'type' => 'text', 'value' => '0.00');
#-------------------------------------------------------------------------------
if (!Is_Null($Attribs)) {
    Array_Union($Default, $Attribs);
}
#-------------------------------------------------------------------------------
$Comp = Comp_Load('Form/Input', $Default);
if (Is_Error($Comp)) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
$Div = new Tag('NOBODY', $Comp);
#-------------------------------------------------------------------------------
$Config = Config();
#-------------------------------------------------------------------------------
$Div->AddChild(new Tag('SPAN', $Config['Executor']['Currency']['Name']));
#-------------------------------------------------------------------------------
return $Div;
#-------------------------------------------------------------------------------
Beispiel #11
0
<?php

#-------------------------------------------------------------------------------
/** @author Великодный В.В. (Joonte Ltd.) */
/******************************************************************************/
/******************************************************************************/
$__args_list = array('TemplateID', 'Pattern');
/******************************************************************************/
eval(COMP_INIT);
/******************************************************************************/
/******************************************************************************/
$Template = array('IsSession' => FALSE, 'Columns' => array('SelectID' => array('Hidden' => '')), 'Query' => array('InPage' => 5), 'Appearance' => array('IsSorted' => FALSE, 'IsDataMode' => FALSE), 'Cut' => array('Comps' => array('Before' => '', 'After' => '')), 'Comps' => array('Before' => array(), 'After' => array('Rows' => array('Comp' => 'Tables/Forms/Data', 'Args' => array('DataModeID' => 'Vertical')))));
#-------------------------------------------------------------------------------
if (!Is_Null($Pattern)) {
    Array_Union($Template, $Pattern);
}
#-------------------------------------------------------------------------------
$Comp = Comp_Load('Tables/Super', $TemplateID, $Template);
if (Is_Error($Comp)) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
return $Comp;
#-------------------------------------------------------------------------------
Beispiel #12
0
     $LinkID = UniqID('ID');
     #---------------------------------------------------------------------------
     $Links =& Links();
     #---------------------------------------------------------------------------
     $Links[$LinkID] =& $A;
     #---------------------------------------------------------------------------
     $Comp = Comp_Load('Form/Prompt', $LinkID, $Item['Prompt']);
     if (Is_Error($Comp)) {
         return ERROR | @Trigger_Error(500);
     }
     #---------------------------------------------------------------------------
     unset($Links[$LinkID]);
 }
 #-----------------------------------------------------------------------------
 if (isset($Item['Attribs'])) {
     Array_Union($A->Attribs, $Item['Attribs']);
 }
 #-----------------------------------------------------------------------------
 $Inner = $Item['Href'] ? $A : new Tag('SPAN', array('class' => 'MenuLeft'), $Text);
 #-----------------------------------------------------------------------------
 $DOM->AddChild('MenuLeftCenter', $Inner);
 #-----------------------------------------------------------------------------
 $Level = $Item['Level'];
 #-----------------------------------------------------------------------------
 $Adding = new Tag('TR');
 #-----------------------------------------------------------------------------
 if ($Level > 1) {
     #---------------------------------------------------------------------------
     for ($i = 1; $i < $Level; $i++) {
         $Adding->AddChild(new Tag('TD', array('width' => 10)));
     }
Beispiel #13
0
    return ERROR | @Trigger_Error(500);
}
foreach ($Chain as $Pattern) {
    if (isset($Pattern['Cut'])) {
        Array_Cut($Template, $Pattern['Cut']);
    }
    Array_Union($Template, $Pattern);
}
$Columns =& $Template['Columns'];
foreach (Array_Keys($Columns) as $ColumnID) {
    $Column = $Template['Column'];
    $Add = $Column['Add'];
    if (isset($Column['Cut'])) {
        Array_Cut($Add, $Column['Cut']);
    }
    Array_Union($Add, $Columns[$ColumnID]);
    $Columns[$ColumnID] = $Add;
}
$Query =& $Template['Query'];
$Args =& Args();
$IsFlush = isset($Args['IsFlush']) && (int) $Args['IsFlush'];
if ($IsFlush) {
    $Args = array();
}
$Session = new Session(isset($_COOKIE['SessionID']) ? (string) $_COOKIE['SessionID'] : UniqID());
$IsSession = $Session->Load();
if (!Is_Error($IsSession) && $Template['IsSession']) {
    $KeyID = Md5($TemplateID);
    if (isset($Session->Data[$KeyID]) && !$IsFlush) {
        $Data = $Session->Data[$KeyID];
        if (isset($Data['Index'])) {
Beispiel #14
0
function System_XML($Element, $HostsIDs = array())
{
    /****************************************************************************/
    $__args_types = array('string', 'array,string');
    #-----------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /****************************************************************************/
    $HostsIDs = System_HostsIDs($Element, $HostsIDs);
    if (Is_Error($HostsIDs)) {
        return ERROR | @Trigger_Error('[System_XML]: список хостов содержащих элемент не найдены');
    }
    #-----------------------------------------------------------------------------
    $IsUseCache = (bool) (Preg_Match('/^tmp\\//', $Element) < 1);
    #-----------------------------------------------------------------------------
    if ($IsUseCache) {
        #---------------------------------------------------------------------------
        $CacheID = SPrintF('System_XML[%s]', Md5(SPrintF('%s-%s', Implode(':', $HostsIDs), $Element)));
        #---------------------------------------------------------------------------
        $Result = CacheManager::get($CacheID);
        if ($Result) {
            return $Result;
        }
    }
    #-----------------------------------------------------------------------------
    $Result = array();
    #-----------------------------------------------------------------------------
    foreach (Array_Reverse($HostsIDs) as $HostID) {
        #---------------------------------------------------------------------------
        $Path = SPrintF('%s/hosts/%s/%s', SYSTEM_PATH, $HostID, $Element);
        #---------------------------------------------------------------------------
        $File = IO_Read($Path);
        if (Is_Error($File)) {
            return ERROR | @Trigger_Error('[System_XML]: не удалось прочитать XML-файл');
        }
        #---------------------------------------------------------------------------
        $XML = String_XML_Parse($File, FALSE);
        if (Is_Exception($XML)) {
            return ERROR | @Trigger_Error('[System_XML]: не удалось разобрать XML-строку');
        }
        #---------------------------------------------------------------------------
        $Child = Current($XML->Childs);
        #---------------------------------------------------------------------------
        if (isset($Child->Attribs['recursive'])) {
            $Result = array();
        }
        #---------------------------------------------------------------------------
        $Adding = $XML->ToArray();
        #---------------------------------------------------------------------------
        $Adding = $Adding['XML'];
        #---------------------------------------------------------------------------
        Array_Union($Result, $Adding);
    }
    #-----------------------------------------------------------------------------
    if ($IsUseCache) {
        CacheManager::add($CacheID, $Result);
    }
    #-----------------------------------------------------------------------------
    return $Result;
}