コード例 #1
0
ファイル: legacy.php プロジェクト: logue/pukiwiki_adv
function set_timezone($lang = '')
{
    return Time::setTimeZone($lang);
}
コード例 #2
0
ファイル: popular.inc.php プロジェクト: logue/pukiwiki_adv
function plugin_popular_getlist($view, $max = PLUGIN_POPULAR_DEFAULT, $except)
{
    static $localtime;
    if (!isset($localtime)) {
        list($zone, $zonetime) = Time::setTimeZone(DEFAULT_LANG);
        $localtime = UTIME + $zonetime;
    }
    $today = gmdate('Y/m/d', $localtime);
    // $yesterday = gmdate('Y/m/d', strtotime('yesterday', $localtime));
    $yesterday = gmdate('Y/m/d', gmmktime(0, 0, 0, gmdate('m', $localtime), gmdate('d', $localtime) - 1, gmdate('Y', $localtime)));
    $counters = array();
    foreach (Listing::pages() as $page) {
        if (!empty($except) && preg_match("/" . $except . "/", $page)) {
            continue;
        }
        $wiki = Factory::Wiki($page);
        if (!$wiki->isReadable() || $wiki->isHidden() || !$wiki->isValied()) {
            continue;
        }
        //$count_file = COUNTER_DIR . str_replace('.txt','.count', $file);
        $count_file = COUNTER_DIR . Utility::encode($page) . '.count';
        if (file_exists($count_file)) {
            $array = file($count_file);
            $count = rtrim($array[0]);
            $date = rtrim($array[1]);
            $today_count = rtrim($array[2]);
            $yesterday_count = rtrim($array[3]);
            $counters['_' . $page] = 0;
            if ($view == 'today' or $view == 'recent') {
                // $pageが数値に見える(たとえばencode('BBS')=424253)とき、
                // array_splice()によってキー値が変更されてしまうのを防ぐ
                // ため、キーに '_' を連結する
                if ($today == $date) {
                    $counters['_' . $page] = $today_count;
                }
            }
            if ($view == 'yesterday' or $view == 'recent') {
                if ($today == $date) {
                    $counters['_' . $page] += $yesterday_count;
                } elseif ($yesterday == $date) {
                    $counters['_' . $page] += $today_count;
                }
            }
            if ($view == 'total') {
                $counters['_' . $page] = $count;
            }
            if ($counters['_' . $page] == 0) {
                unset($counters['_' . $page]);
            }
        }
    }
    asort($counters, SORT_NUMERIC);
    // BugTrack2/106: Only variables can be passed by reference from PHP 5.0.5
    $counters = array_reverse($counters, TRUE);
    // with array_splice()
    if ($max && $max != 0) {
        $counters = array_splice($counters, '0', $max);
    }
    return $counters;
}