#-------------------------------------------------------------------------------
if (Is_Error(System_Load('modules/Authorisation.mod'))) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
$Args = Args();
#-------------------------------------------------------------------------------
$Code = (string) @$Args['Code'];
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
if (!$Code) {
    return new gException('NO_CODE', 'Введите ПромоКод');
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$Code = DB_Escape($Code);
#-------------------------------------------------------------------------------
$PromoCode = DB_Select('PromoCodes', '*', array('UNIQ', 'Where' => SPrintF("`Code` = '%s'", $Code)));
#-------------------------------------------------------------------------------
switch (ValueOf($PromoCode)) {
    case 'error':
        return ERROR | @Trigger_Error(500);
    case 'exception':
        return new gException('PROMOCODE_NOT_FOUND', 'Промокод не найден. Проверьте правильность ввода.');
    case 'array':
        break;
    default:
        return ERROR | @Trigger_Error(101);
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
Esempio n. 2
0
/** @author Alex Keda, for www.host-food.ru */
/******************************************************************************/
/******************************************************************************/
eval(COMP_INIT);
/******************************************************************************/
/******************************************************************************/
$Args = Args();
#-------------------------------------------------------------------------------
$FileID = (int) @$Args['FileID'];
$TypeID = (string) @$Args['TypeID'];
#-------------------------------------------------------------------------------
if (Is_Error(System_Load('modules/Authorisation.mod', 'libs/HTMLDoc.php', 'libs/Upload.php'))) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
$TypeID = DB_Escape($TypeID);
#-------------------------------------------------------------------------------
$FileData = DB_Select($TypeID, '*', array('UNIQ', 'ID' => $FileID));
#-------------------------------------------------------------------------------
switch (ValueOf($FileData)) {
    case 'error':
        return ERROR | @Trigger_Error(500);
    case 'exception':
        return ERROR | @Trigger_Error(400);
    case 'array':
        #---------------------------------------------------------------------------
        $Permission = Permission_Check('EdeskRead', (int) $GLOBALS['__USER']['ID'], (int) $FileData['UserID']);
        #---------------------------------------------------------------------------
        switch (ValueOf($Permission)) {
            case 'error':
                return ERROR | @Trigger_Error(500);
Esempio n. 3
0
if (Is_Error(System_Load('libs/Image.php'))) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
if (!Comp_IsLoaded('Clauses/ImagesGallery')) {
    #-----------------------------------------------------------------------------
    $Links =& Links();
    # Коллекция ссылок
    $DOM =& $Links['DOM'];
    #-----------------------------------------------------------------------------
    $Script = new Tag('SCRIPT', array('type' => 'text/javascript', 'src' => 'SRC:{Js/ClauseImage.js}'));
    #-----------------------------------------------------------------------------
    $DOM->AddChild('Head', $Script);
}
#-------------------------------------------------------------------------------
$Images = DB_Select('ClausesFiles', array('ID', 'Comment', 'FileData'), array('Where' => SPrintF("`ClauseID` = %u AND `FileName` LIKE '%s%%'", $ClauseID, DB_Escape($Prefix))));
#-------------------------------------------------------------------------------
switch (ValueOf($Images)) {
    case 'error':
        return ERROR | @Trigger_Error(500);
    case 'exception':
        return new Tag('SPAN', 'Изображений не найдено');
    case 'array':
        #---------------------------------------------------------------------------
        $Table = new Tag('TABLE', array('cellspacing' => 10));
        #---------------------------------------------------------------------------
        $Tr = new Tag('TR');
        #---------------------------------------------------------------------------
        foreach ($Images as $Image) {
            #-------------------------------------------------------------------------
            if (Count($Tr->Childs) % $Groups == 0) {
Esempio n. 4
0
function DB_Insert($TableID, $Columns)
{
    /****************************************************************************/
    $__args_types = array('string', 'array');
    #-----------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /****************************************************************************/
    $Columns = DB_Types($Columns);
    if (Is_Error($Columns)) {
        return ERROR | @Trigger_Error('[DB_Insert]: не удалось произвести преобразование типов');
    }
    #-----------------------------------------------------------------------------
    $Names = array();
    #-----------------------------------------------------------------------------
    $ColumnsIDs = Array_Keys($Columns);
    #-----------------------------------------------------------------------------
    foreach ($ColumnsIDs as $ColumnID) {
        $Names[] = SPrintF('`%s`', $ColumnID);
    }
    #-----------------------------------------------------------------------------
    $String = Implode(',', $Names);
    #-----------------------------------------------------------------------------
    $Sql = SPrintF('INSERT INTO `%s` (%s)', $TableID, $String);
    #-----------------------------------------------------------------------------
    $Values = array();
    #-----------------------------------------------------------------------------
    foreach ($ColumnsIDs as $ColumnID) {
        #---------------------------------------------------------------------------
        $Column = $Columns[$ColumnID];
        #---------------------------------------------------------------------------
        $Values[] = Is_Null($Column) ? 'NULL' : SPrintF("'%s'", DB_Escape($Column));
    }
    #-----------------------------------------------------------------------------
    $Sql = SPrintF("%s VALUES ( %s )", $Sql, Implode(',', $Values));
    #-----------------------------------------------------------------------------
    $Result = DB_Query($Sql);
    #-----------------------------------------------------------------------------
    switch (ValueOf($Result)) {
        case 'error':
            return ERROR | @Trigger_Error('[DB_Insert]: невозможно осуществить запрос для вставки записи');
        case 'true':
            #-------------------------------------------------------------------------
            if (isset($Columns['ID'])) {
                #-----------------------------------------------------------------------
                return (int) $Columns['ID'];
            } else {
                #-----------------------------------------------------------------------
                $Result = DB_Query('SELECT LAST_INSERT_ID()');
                #-----------------------------------------------------------------------
                switch (ValueOf($Result)) {
                    case 'error':
                        return ERROR | @Trigger_Error('[DB_Insert]: невозможно осуществить запрос по взятию идентификатора записи');
                    case 'resource':
                        #-------------------------------------------------------------------
                        Cache_Delete('[DB_Select]');
                        #-------------------------------------------------------------------
                        $Result = Mysql_Fetch_Row($Result);
                        #-------------------------------------------------------------------
                        return (int) Current($Result);
                    default:
                        return ERROR | @Trigger_Error(101);
                }
            }
        default:
            return ERROR | @Trigger_Error(101);
    }
}
Esempio n. 5
0
<?php

#-------------------------------------------------------------------------------
/** @author Великодный В.В. (Joonte Ltd.) */
/******************************************************************************/
/******************************************************************************/
$__args_list = array('ClauseID', 'IsEdit', 'Preview');
/******************************************************************************/
eval(COMP_INIT);
/******************************************************************************/
/******************************************************************************/
$Preview = isset($Preview) ? $Preview : FALSE;
#Debug(SPrintF("[comp/Clauses/Load]: Preview = %s",$Preview));
#-------------------------------------------------------------------------------
$Where = SPrintF("`ID` = %u OR `Partition` = '%s'", $ClauseID, DB_Escape($ClauseID));
#-------------------------------------------------------------------------------
$Clause = DB_Select('Clauses', '*', array('Where' => $Where));
#-------------------------------------------------------------------------------
switch (ValueOf($Clause)) {
    case 'error':
        return ERROR | @Trigger_Error(500);
    case 'exception':
        #---------------------------------------------------------------------------
        $P = new Tag('P');
        #---------------------------------------------------------------------------
        $Parse = '<P><SPAN>К сожалению, необходимая статья не найдена: </SPAN><U>%s</U></P>';
        #---------------------------------------------------------------------------
        $P->AddHTML(SPrintF($Parse, $ClauseID));
        #---------------------------------------------------------------------------
        return array('Title' => 'Статья не найдена', 'DOM' => $P, 'IsExists' => FALSE);
    case 'array':
Esempio n. 6
0
<?php

#-------------------------------------------------------------------------------
/** @author Великодный В.В. (Joonte Ltd.) */
/******************************************************************************/
/******************************************************************************/
$__args_list = array('Pattern');
/******************************************************************************/
eval(COMP_INIT);
/******************************************************************************/
/******************************************************************************/
$Where = SPrintF("`Partition` LIKE '%s' AND `IsPublish` = 'yes'", DB_Escape($Pattern));
#-------------------------------------------------------------------------------
$Clauses = DB_Select('Clauses', array('ID', 'PublicDate', 'ChangedDate', 'EditorID', 'Partition', 'Title', 'Text'), array('Where' => $Where, 'SortOn' => 'PublicDate'));
#-------------------------------------------------------------------------------
switch (ValueOf($Clauses)) {
    case 'error':
        return ERROR | @Trigger_Error(500);
    case 'exception':
        #---------------------------------------------------------------------------
        $Comp = Comp_Load('Information', 'Статьи не найдены.', 'Notice');
        if (Is_Error($Comp)) {
            return ERROR | @Trigger_Error(500);
        }
        #---------------------------------------------------------------------------
        return $Comp;
    case 'array':
        #---------------------------------------------------------------------------
        $Ul = new Tag('UL', array('class' => 'Standard'));
        #---------------------------------------------------------------------------
        foreach ($Clauses as $Clause) {
Esempio n. 7
0
#-------------------------------------------------------------------------------
$Session =& $Template['Session'];
#-------------------------------------------------------------------------------
if (isset($Session['Search'])) {
    $Search = $Session['Search'];
}
#-------------------------------------------------------------------------------
$Args = Args();
#-------------------------------------------------------------------------------
if (isset($Args['Search'])) {
    $Search = $Args['Search'];
}
#-------------------------------------------------------------------------------
if ($Search) {
    #-------------------------------------------------------------------------------
    $dSearch = DB_Escape(SPrintF('%%%s%%', $Search));
    #-------------------------------------------------------------------------------
    $Variants = array();
    #-------------------------------------------------------------------------------
    foreach ($ColumnsIDs as $ColumnID) {
        #-------------------------------------------------------------------------------
        $ColumnID = Preg_Match('/^[a-zA-Z0-9]+$/', $ColumnID) ? SPrintF('`%s`', $ColumnID) : $ColumnID;
        #-------------------------------------------------------------------------------
        $Variants[] = SPrintF("%s LIKE '%s'", $ColumnID, $dSearch);
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
    $Query = Implode(' OR ', $Variants);
    #-------------------------------------------------------------------------------
    $Where = SPrintF('( %s )', $Query);
    #-------------------------------------------------------------------------------
Esempio n. 8
0
#-------------------------------------------------------------------------------
/** @author Великодный В.В. (Joonte Ltd.) */
/******************************************************************************/
/******************************************************************************/
eval(COMP_INIT);
/******************************************************************************/
/******************************************************************************/
$Args = Args();
#-------------------------------------------------------------------------------
$Search = (string) @$Args['Search'];
#-------------------------------------------------------------------------------
if (Is_Error(System_Load('modules/Authorisation.mod'))) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
$Search = DB_Escape($Search);
#-------------------------------------------------------------------------------
$Where = SPrintF("`Email` LIKE '%%%s%%' OR `Name` LIKE '%%%s%%'", $Search, $Search);
#-------------------------------------------------------------------------------
$Users = DB_Select('Users', array('ID', 'Email', 'Name'), array('Limit' => array('Start' => 0, 'Length' => 15), 'Where' => $Where));
#-------------------------------------------------------------------------------
switch (ValueOf($Users)) {
    case 'error':
        return ERROR | @Trigger_Error(500);
    case 'exception':
        return new gException('NO_RESULT', 'Пользователи не найдены');
    case 'array':
        #---------------------------------------------------------------------------
        $Result = array();
        #---------------------------------------------------------------------------
        foreach ($Users as $User) {
Esempio n. 9
0
/******************************************************************************/
/******************************************************************************/
eval(COMP_INIT);
/******************************************************************************/
/******************************************************************************/
$Links =& Links();
# Коллекция ссылок
$DOM =& $Links[$LinkID];
#-------------------------------------------------------------------------------
$TitleTag = $DOM->GetByTagName('TITLE');
#-------------------------------------------------------------------------------
$Title = Current($TitleTag);
#-------------------------------------------------------------------------------
$Title->AddText(SPrintF('%s - %s', Str_Replace('→', '-', $Title->Text), HOST_ID), TRUE);
#-------------------------------------------------------------------------------
$Where = SPrintF("`Partition` = 'Header:%s'", DB_Escape(isset($GLOBALS['_GET']['ServiceID']) ? $GLOBALS['_GET']['ServiceID'] : $GLOBALS['__URI']));
#-------------------------------------------------------------------------------
$Clauses = DB_Select('Clauses', 'ID', array('Where' => $Where));
#-------------------------------------------------------------------------------
switch (ValueOf($Clauses)) {
    case 'error':
        return ERROR | @Trigger_Error(500);
    case 'exception':
        # No more...
        break;
    case 'array':
        #-------------------------------------------------------------------------------
        $Clause = Current($Clauses);
        #-------------------------------------------------------------------------------
        $Comp = Comp_Load('Clauses/Load', $Clause['ID']);
        if (Is_Error($Comp)) {
Esempio n. 10
0
function Permission_Check($Name, $UserID, $OwnerID = 1)
{
    /****************************************************************************/
    $__args_types = array('string', 'integer', 'integer');
    #-----------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /****************************************************************************/
    if (Is_Error(System_Load('libs/Tree.php'))) {
        return ERROR | @Trigger_Error(500);
    }
    #-----------------------------------------------------------------------------
    if (!$Name) {
        return new gException('RULE_NAME_IS_EMPTY', 'Введите имя правила доступа');
    }
    #-----------------------------------------------------------------------------
    $Rules = DB_Select('Permissions', '*', array('Where' => SPrintF("'%s' LIKE `Name`", DB_Escape($Name)), 'SortOn' => 'Metric'));
    #-----------------------------------------------------------------------------
    switch (ValueOf($Rules)) {
        case 'error':
            return ERROR | @Trigger_Error('[Permission_Check]: не удалось получить права доступа');
        case 'exception':
            return FALSE;
        case 'array':
            #-------------------------------------------------------------------------
            $User = DB_Select('Users', array('ID', 'GroupID'), array('UNIQ', 'ID' => $UserID));
            #-------------------------------------------------------------------------
            switch (ValueOf($User)) {
                case 'error':
                    return ERROR | @Trigger_Error('[Permission_Check]: не удалось выбрать пользователя осуществляющего запрос');
                case 'exception':
                    return new gException('USER_NOT_FOUND', 'Пользователь осуществляющий запрос доступа не найден');
                case 'array':
                    #---------------------------------------------------------------------
                    $Owner = DB_Select('Users', array('ID', 'GroupID', 'OwnerID', 'IsManaged'), array('UNIQ', 'ID' => $OwnerID));
                    #---------------------------------------------------------------------
                    switch (ValueOf($Owner)) {
                        case 'error':
                            return ERROR | @Trigger_Error('[Permission_Check]: не удалось выбрать владельца');
                        case 'exception':
                            return new gException('OWNER_NOT_FOUND', 'Владелец объекта не найден');
                        case 'array':
                            #-----------------------------------------------------------------
                            $IsPermission = FALSE;
                            #-----------------------------------------------------------------
                            foreach ($Rules as $Rule) {
                                #---------------------------------------------------------------
                                $Entrance = Tree_Entrance('Groups', (int) $Rule['UserGroupID']);
                                #---------------------------------------------------------------
                                switch (ValueOf($Entrance)) {
                                    case 'error':
                                        return ERROR | @Trigger_Error('[Permission_Check]: не удалось определить дочерние группы правила доступа');
                                    case 'exception':
                                        return new gException('CHILD_GROUPS_PERMISSION_RULE_NOT_FOUND', 'Дочерние группы правила доступа не определены');
                                    case 'array':
                                        # No more...
                                        break;
                                    default:
                                        return ERROR | @Trigger_Error(101);
                                }
                                #---------------------------------------------------------------
                                if (In_Array($User['GroupID'], $Entrance) || $UserID == $Rule['UserID']) {
                                    #-------------------------------------------------------------
                                    if ($User['ID'] != $Owner['ID'] && ($User['ID'] != $Owner['OwnerID'] || !$Owner['IsManaged'])) {
                                        #-----------------------------------------------------------
                                        $Entrance = Tree_Entrance('Groups', (int) $Rule['OwnerGroupID']);
                                        #-----------------------------------------------------------
                                        switch (ValueOf($Entrance)) {
                                            case 'error':
                                                return ERROR | @Trigger_Error('[Permission_Check]: не удалось определить дочерние группы правила делегирования');
                                            case 'exception':
                                                return new gException('CHILD_GROUPS_DELIGATE_RULE_NOT_FOUND', 'Дочерние группы правила делегирования не определены');
                                            case 'array':
                                                # No more...
                                                break;
                                            default:
                                                return ERROR | @Trigger_Error(101);
                                        }
                                        #-----------------------------------------------------------
                                        if (In_Array($Owner['GroupID'], $Entrance) || $OwnerID == $Rule['OwnerID']) {
                                            #---------------------------------------------------------
                                            $IsPermission = $Rule['IsAccess'];
                                        }
                                    } else {
                                        $IsPermission = $Rule['IsAccess'];
                                    }
                                }
                            }
                            #-----------------------------------------------------------------
                            return $IsPermission;
                        default:
                            return ERROR | @Trigger_Error(101);
                    }
                default:
                    return ERROR | @Trigger_Error(101);
            }
        default:
            return ERROR | @Trigger_Error(101);
    }
}