Пример #1
0
function dumbCronScheduler($checkOnly = true)
{
    $context = Model_Context::getInstance();
    $now = Timestamp::getUNIXtime();
    $dumbCronStamps = Setting::getServiceSetting('dumbCronStamps', serialize(array('1m' => 0, '5m' => 0, '30m' => 0, '1h' => 0, '2h' => 0, '6h' => 0, '12h' => 0, '24h' => 0, 'Daily' => 0)), true);
    $dumbCronStamps = unserialize($dumbCronStamps);
    $schedules = array('1m' => 60, '5m' => 60 * 5, '10m' => 60 * 10, '30m' => 60 * 30, '1h' => 60 * 60, '2h' => 60 * 60 * 2, '6h' => 60 * 60 * 6, '12h' => 60 * 60 * 12, '24h' => 60 * 60 * 24, 'Daily' => 60 * 60 * 24, '1w' => 60 * 60 * 24 * 7);
    /* Events: Cron1m, Cron5m, Cron30m, Cron1h, Cron2h, Cron6h, Cron12h */
    $log_file = __TEXTCUBE_CACHE_DIR__ . '/cronlog.txt';
    $log = fopen($log_file, "a");
    foreach ($schedules as $d => $diff) {
        if (!isset($dumbCronStamps[$d])) {
            $dumbCronStamps[$d] = 0;
        }
        if ($now > $diff + $dumbCronStamps[$d]) {
            if ($checkOnly && eventExists("Cron{$d}")) {
                fclose($log);
                return true;
            }
            fireEvent("Cron{$d}", null, $now);
            if ($d == '6h') {
                importlib('model.blog.trash');
                trashVan();
            }
            fwrite($log, date('Y-m-d H:i:s') . ' ' . $context->getProperty('blog.name') . " Cron{$d} executed ({$_SERVER['REQUEST_URI']})\r\n");
            $dumbCronStamps[$d] = $now;
        }
    }
    fclose($log);
    /* Keep just 1000 lines */
    $logcontent = explode("\r\n", file_get_contents($log_file));
    $logcontent = implode("\r\n", array_slice($logcontent, -1000));
    $log = fopen($log_file, "w");
    fwrite($log, $logcontent);
    fclose($log);
    Setting::setServiceSetting('dumbCronStamps', serialize($dumbCronStamps), true);
    return false;
}
Пример #2
0
<?php

/// Copyright (c) 2004-2011, Needlworks  / Tatter Network Foundation
/// All rights reserved. Licensed under the GPL.
/// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT)
require ROOT . '/library/preprocessor.php';
if (eventExists('AccessFreeSlogan')) {
    $info = fireEvent('AccessFreeSlogan', implode('/', $URLInfo['fragment']), $URLInfo);
    if (Validator::id($info)) {
        $entries = array();
        $objEntry = new Notice();
        if ($objEntry->doesExist($info)) {
            list($entries) = getEntryWithPaging($blogid, $info, true);
        } else {
            $objEntry = new Post();
            if ($objEntry->doesExist($info)) {
                list($entries, $paging) = getEntryWithPaging($blogid, $info);
            }
        }
        fireEvent('OBStart');
        require ROOT . '/interface/common/blog/begin.php';
        if (empty($entries)) {
            header('HTTP/1.1 404 Not Found');
            if (empty($skin->pageError)) {
                dress('article_rep', '<div class="TCwarning">' . _text('존재하지 않는 페이지입니다.') . '</div>', $view);
            } else {
                dress('article_rep', NULL, $view);
                dress('page_error', $skin->pageError, $view);
            }
            unset($paging);
        } else {
Пример #3
0
{
    $id = $from ?: getLastId();
    $timer = time();
    while (!($events = getLastEvents($id))) {
        sleep(1);
        if (time() - $timer >= 5) {
            return [];
        }
    }
    return $events;
}
return function (array $request) {
    $query = $request['query'];
    if (array_key_exists('t', $query)) {
        $id = (int) $query['t'];
        if (!eventExists($id)) {
            return createResponse('', 400);
        }
    } else {
        $id = getLastId();
    }
    session_write_close();
    $events = waitForEvent($id);
    session_start();
    if (0 === count($events)) {
        $response = ['t' => $id];
    } else {
        $currentUser = currentUser();
        if ($currentUser) {
            $response = ['events' => $events, 'cash' => getCashById(currentUser()['id']) / 100, 't' => $events[0]['id']];
        } else {