Exemplo n.º 1
0
function Is_Keys_Exists($Array, $Key)
{
    /****************************************************************************/
    $__args_types = array('array', 'string,int');
    #-----------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /****************************************************************************/
    Array_Shift($__args__);
    #-----------------------------------------------------------------------------
    foreach ($__args__ as $__arg__) {
        #---------------------------------------------------------------------------
        if (!isset($Array[$__arg__])) {
            return FALSE;
        }
    }
    #-----------------------------------------------------------------------------
    return TRUE;
}
Exemplo n.º 2
0
Header('Content-type: text/plain; charset=utf-8');
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$__SYSLOG =& $GLOBALS['__SYSLOG'];
#-------------------------------------------------------------------------------
echo SPrintF("%s обновлений\n", $Commit ? 'Применение' : 'Проверка');
#-------------------------------------------------------------------------------
echo "Получение снимка файловой системы\n--\n";
#-------------------------------------------------------------------------------
$Snapshot = array();
#-------------------------------------------------------------------------------
$Folders = array('hosts', 'styles', 'db', 'scripts', 'others', 'patches');
#-------------------------------------------------------------------------------
$HostsIDs = $GLOBALS['HOST_CONF']['HostsIDs'];
#-------------------------------------------------------------------------------
Array_Shift($HostsIDs);
#-------------------------------------------------------------------------------
foreach ($Folders as $Folder) {
    #-------------------------------------------------------------------------------
    foreach ($HostsIDs as $HostID) {
        #-------------------------------------------------------------------------------
        $Path = SPrintF('%s/%s/%s', SYSTEM_PATH, $Folder, $HostID);
        #-------------------------------------------------------------------------------
        if (!File_Exists($Path)) {
            continue;
        }
        #-------------------------------------------------------------------------------
        $Files = IO_Files($Path);
        if (Is_Error($Files)) {
            return SPrintF("---\n%s\n---\n", Implode("\n", Array_Slice($__SYSLOG, Count($__SYSLOG) - 20)));
        }
Exemplo n.º 3
0
    $msg = new DispatchMsg($Replace, (int) $User, $Task['Params']['FromID']);
    $IsSend = NotificationManager::sendMsg($msg, $Methods);
    #-------------------------------------------------------------------------
    switch (ValueOf($IsSend)) {
        case 'error':
            return ERROR | @Trigger_Error(500);
        case 'exception':
            # Исключение - системные юзеры, например...
            $SendedIDs[] = $User;
            Array_Shift($SendToIDs);
            break;
        case 'true':
            #-------------------------------------------------------------------------
            $Count++;
            $SendedIDs[] = $User;
            Array_Shift($SendToIDs);
            #-------------------------------------------------------------------------
            break;
        default:
            return ERROR | @Trigger_Error(101);
    }
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#Debug(SPrintF('[comp/Tasks/Dispatch]: SendToIDs = %s; SendedIDs = %s;',Implode(',',$SendToIDs),Implode(',',$SendedIDs)));
#-------------------------------------------------------------------------------
# сохраняем параметры задачи
$Task['Params']['SendToIDs'] = Implode(',', Array_Filter($SendToIDs));
$Task['Params']['SendedIDs'] = Implode(',', Array_Filter($SendedIDs));
$UTasks = array('Params' => $Task['Params']);
$IsUpdate = DB_Update('Tasks', $UTasks, array('ID' => $Task['ID']));
Exemplo n.º 4
0
 private function Fetch($URLs, $Tries)
 {
     $this->Requests = array();
     $Master = cURL_Multi_Init();
     $WindowSize = 10;
     if ($WindowSize > Count($URLs)) {
         $WindowSize = Count($URLs);
     }
     for ($i = 0; $i < $WindowSize; $i++) {
         $URL = Array_Shift($URLs);
         $this->CreateHandle($Master, $URL);
     }
     unset($URL, $WindowSize, $i);
     do {
         while (($Exec = cURL_Multi_Exec($Master, $Running)) === CURLM_CALL_MULTI_PERFORM) {
         }
         if ($Exec !== CURLM_OK) {
             break;
         }
         while ($Done = cURL_Multi_Info_Read($Master)) {
             $Slave = $Done['handle'];
             $URL = cURL_GetInfo($Slave, CURLINFO_EFFECTIVE_URL);
             $Code = cURL_GetInfo($Slave, CURLINFO_HTTP_CODE);
             $Data = cURL_Multi_GetContent($Slave);
             $Request = $this->Requests[(int) $Slave];
             $HeaderSize = cURL_GetInfo($Slave, CURLINFO_HEADER_SIZE);
             $Header = SubStr($Data, 0, $HeaderSize);
             $Data = SubStr($Data, $HeaderSize);
             if (isset($Done['error'])) {
                 $this->Log('{yellow}cURL Error: {yellow}' . $Done['error'] . '{normal} - ' . $URL);
                 $this->URLsToFetch[] = array('URL' => $URL, 'File' => $Request);
             } else {
                 if ($Code === 304) {
                     $this->Log('{yellow}Not Modified{normal} - ' . $URL);
                 } else {
                     if ($Code !== 200) {
                         $this->Log('{yellow}HTTP Error ' . $Code . '{normal} - ' . $URL);
                         if ($Code !== 404) {
                             $this->URLsToFetch[] = array('URL' => $URL, 'File' => $Request);
                         }
                     } else {
                         $LengthExpected = cURL_GetInfo($Slave, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
                         $LengthDownload = cURL_GetInfo($Slave, CURLINFO_SIZE_DOWNLOAD);
                         if ($LengthExpected !== $LengthDownload) {
                             $this->Log('{lightred}Wrong Length {normal}(' . $LengthDownload . ' != ' . $LengthExpected . '){normal} - ' . $URL);
                             $this->URLsToFetch[] = array('URL' => $URL, 'File' => $Request);
                         } else {
                             if (Preg_Match('/^ETag: (.+)$/m', $Header, $Test) === 1) {
                                 $this->ETags[$Request] = Trim($Test[1]);
                             }
                             if ($this->HandleResponse($Request, $Data) === true) {
                                 $this->Log('{green}Fetched{normal} - ' . $URL);
                             } else {
                                 $this->Log('{green}Not Modified{normal} - ' . $URL);
                             }
                         }
                     }
                 }
             }
             if (Count($URLs)) {
                 $URL = Array_Shift($URLs);
                 $this->CreateHandle($Master, $URL);
             }
             cURL_Multi_Remove_Handle($Master, $Slave);
             cURL_Close($Slave);
             unset($Request, $Slave);
         }
         if ($Running) {
             cURL_Multi_Select($Master, 5);
         }
     } while ($Running);
     cURL_Multi_Close($Master);
 }
Exemplo n.º 5
0
Description: This template displays the gallery thumbnail and enables the user to navigate through all images.
Version: 1.0.0
Author: Dennis Hoppe
Author URI: http://DennisHoppe.de
*/
if ($thumb_id = Get_Post_Thumbnail_ID($this->gallery->id)) {
    // Try to find this image in the gallery
    foreach ($this->gallery->images as $index => $image) {
        if ($thumb_id == $image->ID) {
            $thumb = $image;
            unset($this->gallery->images[$index]);
            break;
        }
    }
} else {
    $thumb = Array_Shift($this->gallery->images);
}
?>
<div class="gallery fancy-gallery <?php 
echo BaseName(__FILE__, '.php');
?>
" id="gallery_<?php 
echo $this->gallery->id;
?>
">
  <a href="<?php 
echo $thumb->href;
?>
" title="<?php 
echo HTMLSpecialChars($thumb->title);
?>
Exemplo n.º 6
0
 function Tag($Name = '')
 {
     /******************************************************************************/
     $__args_types = array('string', 'integer,double,string,array,object');
     #-------------------------------------------------------------------------------
     $__args__ = Func_Get_Args();
     eval(FUNCTION_INIT);
     /******************************************************************************/
     $this->Name = $Name;
     #-------------------------------------------------------------------------------
     if ($Name == 'FORM') {
         #-------------------------------------------------------------------------------
         #Debug(SPrintF('[system/classes/auto/Tag]: before __args__ = %s',print_r($__args__,true)));
         $Comp = Comp_Load('Form/Input', array('name' => 'CSRF', 'type' => 'hidden', 'value' => $GLOBALS['CSRF']));
         if (Is_Error($Comp)) {
             return ERROR | @Trigger_Error(500);
         }
         #-------------------------------------------------------------------------------
         if (isset($__args__[2])) {
             #-------------------------------------------------------------------------------
             $__args__[2]->AddChild($Comp);
             #-------------------------------------------------------------------------------
         } else {
             #-------------------------------------------------------------------------------
             $__args__[2] = $Comp;
             #-------------------------------------------------------------------------------
         }
         #-------------------------------------------------------------------------------
         #Debug(SPrintF('[system/classes/auto/Tag]: after __args__ = %s',print_r($__args__,true)));
         #-------------------------------------------------------------------------------
     }
     #-------------------------------------------------------------------------------
     if (Count($__args__) > 1) {
         #-------------------------------------------------------------------------------
         Array_Shift($__args__);
         #-------------------------------------------------------------------------------
         foreach ($__args__ as $__arg__) {
             #-------------------------------------------------------------------------------
             $TypeID = GetType($__arg__);
             #-------------------------------------------------------------------------------
             if (In_Array($TypeID, array('integer', 'double', 'float', 'string'))) {
                 #-------------------------------------------------------------------------------
                 $__arg__ = (string) $__arg__;
                 #-------------------------------------------------------------------------------
                 if (!Mb_StrLen($__arg__)) {
                     continue;
                 }
                 #-------------------------------------------------------------------------------
                 $Function = 'AddText';
                 #-------------------------------------------------------------------------------
             } else {
                 #-------------------------------------------------------------------------------
                 switch ($TypeID) {
                     case 'object':
                         #-------------------------------------------------------------------------------
                         $Function = 'AddChild';
                         #-------------------------------------------------------------------------------
                         break;
                         #-------------------------------------------------------------------------------
                     #-------------------------------------------------------------------------------
                     case 'array':
                         #-------------------------------------------------------------------------------
                         $Function = 'AddAttribs';
                         #-------------------------------------------------------------------------------
                         break;
                     default:
                         continue 2;
                 }
                 #-------------------------------------------------------------------------------
             }
             #-------------------------------------------------------------------------------
             $this->{$Function}($__arg__);
             #-------------------------------------------------------------------------------
         }
         #-------------------------------------------------------------------------------
     }
     #-------------------------------------------------------------------------------
 }
Exemplo n.º 7
0
            default:
                $TaskResult = array('Task' => $NowTask, 'State' => 'EXCEPTION', 'Text' => 'Задача вернула не предумотренный результат');
        }
        #-----------------------------------------------------------------------------
    } else {
        $TaskResult = array('Task' => $NowTask, 'State' => 'EXCEPTION', 'Text' => 'Задаче не назначен обработчик.');
    }
    #-----------------------------------------------------------------------------
    # Если задача выполнилась полностью или вызвала ошибку, то выбираем следующую
    if ($TaskCount == 0) {
        $NowTask = FALSE;
    }
}
# Устанавливаем след. задачу из массива задач
if (!$NowTask && $TasksArray) {
    $NowTask = Array_Shift($TasksArray);
    $Task['Params']['TasksArray'] = $TasksArray;
}
# Если массив задач кончился
if (!$NowTask && !$TasksArray) {
    Debug("[Tasks/GC]: Задания закончились.");
    #Debug("[Tasks/GC]: След. запуск через сутки.");
    $IsEnded = TRUE;
    $Task['Params'] = array();
}
#-------------------------------------------------------------------------------
# Формируем результат выполнения задачи
if (isset($Task['Result']) && Is_Array($TaskResult)) {
    $Task['Result'] .= SPrintF("%s\n", Implode(', ', $TaskResult));
} else {
    Is_Array($TaskResult) ? $Task['Result'] = SPrintF("%s\n", Implode(', ', $TaskResult)) : ($Task['Result'] = $TaskResult);