Example #1
0
function get_date($format, $timestamp = NULL)
{
    return Time::getZoneTimeDate($format, $timestamp);
}
Example #2
0
<?php

// PukiWiki Plus! - Yet another WikiWikiWeb clone.
// $Id: rules.ini.php,v 1.10.5 2007/06/10 02:08:40 miko Exp $
// Copyright (C)
//   2005-2007 Customized/Patched by Miko.Hoshina
//   2003-2007 PukiWiki Developers Team
//   2001-2002 Originally written by yu-ji
// License: GPL v2 or (at your option) any later version
//
use PukiWiki\Time;
use PukiWiki\Utility;
global $vars, $date_format, $time_format;
/**
 * フィルタルール
 *
 *  正規表現で記述してください。?(){}-*./+\$^|など
 *  は \? のようにクォートしてください。
 *  前後に必ず / を含めてください。行頭指定は ^ を頭に。
 *  行末指定は $ を後ろに。
*/
return array('filter' => array("^(TITLE):(.*)\$" => "", "#tboff(.*)\$" => "", "#skin(.*)\$" => ""), 'datetime' => array('&amp;_now;' => '&epoch{' . time() . '};', '&amp;_date;' => Time::getZoneTimeDate($date_format), '&amp;_time;' => Time::getZoneTimeDate($time_format)), 'str' => array('&now;' => '\\&epoch\\{' . time() . '\\};', '&date;' => Time::getZoneTimeDate($date_format), '&time;' => Time::getZoneTimeDate($time_format), '&page;' => isset($vars['page']) ? Utility::getPageNameShort($vars['page']) : null, '&fpage;' => isset($vars['page']) ? $vars['page'] : null, '&t;' => "\t"));
/* End of file rules.ini.php */
/* Location: ./wiki-common/rules.ini.php */
Example #3
0
 /**
  * 更新日時
  */
 public function getDate()
 {
     return Time::getZoneTimeDate('Y/m/d H:i:s', $this->fileinfo->getMTime());
 }
Example #4
0
 /**
  * 添付ファイル一覧
  * @return string
  */
 private function getAttaches()
 {
     // TODO: UPLOAD_DIRの参照方法の変更
     global $_LANG;
     $ret = array();
     $exists = false;
     $attaches = $this->wiki->attach(false);
     if (!empty($attaches)) {
         $ret[] = '<dl class="list-inline">';
         $ret[] = '<dt>' . $_LANG['skin']['attach_title'] . '</dt>';
         foreach ($attaches as $filename => $files) {
             if (!isset($files[0])) {
                 continue;
             }
             $fileinfo = new AttachFile($this->page, $filename);
             $exists = true;
             if (!$fileinfo->has()) {
                 continue;
             }
             $logfileinfo = new AttachFile($this->page, $filename, 'log');
             $count = $logfileinfo->has() ? $logfileinfo->head(1) : '0';
             $ret[] = '<dd><a href="' . Router::get_cmd_uri('attach', null, null, array('pcmd' => 'open', 'refer' => $this->page, 'age' => 0, 'openfile' => $filename)) . '" title="' . Time::getZoneTimeDate('Y/m/d H:i:s', $fileinfo->time()) . ' ' . sprintf('%01.1f', round($fileinfo->getSize() / 1024, 1)) . 'KB' . '"><span class="fa fa-download"></span>' . Utility::htmlsc($filename) . '</a> ' . '<a href="' . Router::get_cmd_uri('attach', null, null, array('pcmd' => 'info', 'refer' => $this->page, 'file' => $filename)) . '" class="btn btn-default btn-xs" title="' . $_LANG['skin']['attach_info'] . '">' . '<span class="fa fa-info"></span></a>' . '</dd>';
         }
         $ret[] = '</dl>';
     }
     return $exists ? join("\n", $ret) : null;
 }
Example #5
0
function plugin_calendar_convert()
{
    global $vars, $post, $get, $_labels;
    //global $_calendar_plugin_edit, $_calendar_plugin_empty;
    global $_calendar_msg;
    if (!isset($vars['page'])) {
        return '';
    }
    /* from Plus! */
    $today_view = TRUE;
    $today_args = 'view';
    $date_str = Time::getZoneTimeDate('Ym');
    $base = Utility::stripBracket($vars['page']);
    $today_view = TRUE;
    if (func_num_args() > 0) {
        $args = func_get_args();
        foreach ($args as $arg) {
            if (is_numeric($arg) && strlen($arg) == 6) {
                $date_str = $arg;
            } else {
                if ($arg == 'off') {
                    $today_view = FALSE;
                } else {
                    if ($arg == 'past' || $arg == 'pastex' || $arg == 'future' || $arg == 'futureex' || $arg == 'view' || $arg == 'viewex') {
                        /* from Plus! */
                        $today_args = $arg;
                    } else {
                        $base = Utility::stripBracket($arg);
                    }
                }
            }
        }
    }
    if ($base == '*') {
        $base = '';
        $prefix = '';
    } else {
        $prefix = $base . '/';
    }
    $s_base = Utility::htmlsc($base);
    $s_prefix = Utility::htmlsc($prefix);
    $yr = substr($date_str, 0, 4);
    $mon = substr($date_str, 4, 2);
    if ($yr != get_date('Y') || $mon != get_date('m')) {
        $now_day = 1;
        $other_month = 1;
    } else {
        $now_day = get_date('d');
        $other_month = 0;
    }
    $today = getdate(mktime(0, 0, 0, $mon, $now_day, $yr));
    $m_num = $today['mon'];
    $d_num = $today['mday'];
    $year = $today['year'];
    $f_today = getdate(mktime(0, 0, 0, $m_num, 1, $year));
    $wday = $f_today['wday'];
    $day = 1;
    $m_name = Time::format($today[0], false, $_calendar_msg['_calendar_title_format']);
    $y = substr($date_str, 0, 4) + 0;
    $m = substr($date_str, 4, 2) + 0;
    $format = '%04d%02d';
    $prev_link = Router::get_cmd_uri('calendar', '', '', array('file' => $base, 'mode' => $today_args, 'date' => $m == 1 ? sprintf($format, $y - 1, 12) : sprintf($format, $y, $m - 1)));
    $next_link = Router::get_cmd_uri('calendar', '', '', array('file' => $base, 'mode' => $today_args, 'date' => $m == 12 ? sprintf($format, $y + 1, 1) : sprintf($format, $y, $m + 1)));
    $this_date_str = sprintf($format, $y, $m);
    $page_YM = sprintf('%04d-%02d', $y, $m);
    $ret = '';
    if ($today_view === TRUE) {
        $ret .= '<div class="clearfix">' . "\n" . '<div class="style_calendar_viewer">' . "\n";
        // カレンダーのdivタグ($today_view有効時のみ出力)
    }
    $ret .= <<<EOD
<table class="table table-bordered style_calendar" summary="calendar" data-sortable="false">
\t<thead>
\t\t<tr>
\t\t\t<td class="style_calendar_top" colspan="7">
\t\t\t\t<nav>
\t\t\t\t\t<ul class="style_calendar_navi">
\t\t\t\t\t\t<li class="style_calendar_prev"><a href="{$prev_link}">&lt;&lt;</a></li>
\t\t\t\t\t\t<li class="style_calendar_title"><strong>{$m_name}</strong></li>
\t\t\t\t\t\t<li class="style_calendar_next"><a href="{$next_link}">&gt;&gt;</a></li>
\t\t\t\t\t</ul>
\t\t\t\t</nav>
EOD;
    if ($vars['cmd'] == 'calendar' || $vars['cmd'] == 'calendar_viewer') {
        $base_link = Factory::Wiki($base)->uri();
    } else {
        $base_link = Router::get_cmd_uri('calendar', '', '', array('file' => $base, 'mode' => $today_args, 'date' => sprintf($format, $y, $m)));
    }
    if ($prefix) {
        $ret .= "\n" . '				[<a href="' . $base_link . '">' . $s_base . '</a>]';
    }
    $ret .= "\n" . '			</td>' . "\n" . '		</tr>' . "\n" . '	</thead>' . "\n" . '	<tbody>' . "\n" . '		<tr>' . "\n";
    for ($i = 0; $i < 7; $i++) {
        if ($i == 0) {
            $class = 'week_sun';
        } else {
            if ($i == 6) {
                $class = 'week_sat';
            } else {
                $class = 'week_day';
            }
        }
        $ret .= '			<th class="style_calendar_week"><abbr title="' . $_labels['week'][$i][1] . '" class="' . $class . '">' . $_labels['week'][$i][0] . '</abbr></th>' . "\n";
    }
    unset($i, $class);
    $ret .= '		</tr>' . "\n" . '		<tr>' . "\n";
    // Blank
    for ($i = 0; $i < $wday; $i++) {
        $ret .= '			<td class="blank-cell"></td>' . "\n";
    }
    while (checkdate($m_num, $day, $year)) {
        $dt = sprintf(PLUGIN_CALENDAR_PAGENAME_FORMAT, $year, $m_num, $day);
        $page = $prefix . $dt;
        $s_page = Utility::htmlsc($page);
        $wiki = Factory::Wiki($page);
        if ($wday == 0 && $day > 1) {
            $ret .= '		</tr>' . "\n" . '		<tr>' . "\n";
        }
        /* from Plus! */
        $h_today = PublicHolidayFactory::factory('JP', $year, $m_num, $day);
        $hday = $h_today['rc'];
        $style = 'style_calendar_day';
        // Weekday
        if (!$other_month && $day == $today['mday'] && $m_num == $today['mon'] && $year == $today['year']) {
            // Today
            $style = 'style_calendar_today';
        } else {
            if ($hday !== 0) {
                // Holiday
                $style = 'style_calendar_holiday';
            } else {
                if ($wday == 0) {
                    // Sunday
                    $style = 'style_calendar_sun';
                } else {
                    if ($wday == 6) {
                        // Saturday
                        $style = 'style_calendar_sat';
                    }
                }
            }
        }
        if ($wiki->has()) {
            $link = '<a href="' . $wiki->uri() . '" title="' . $s_page . '"><strong>' . $day . '</strong></a>';
        } else {
            if (PKWK_READONLY) {
                $link = $day;
            } else {
                $link = '<a href="' . $wiki->uri('edit', array('refer' => $base)) . '" title="' . $s_page . '" rel="nofollow">' . $day . '</a>';
            }
        }
        $ret .= '<td class="style_td ' . $style . '">' . $link . '</td>' . "\n";
        ++$day;
        $wday = ++$wday % 7;
    }
    if ($wday > 0) {
        while ($wday++ < 7) {
            // Blank
            $ret .= '<td class="style_td_blank"></td>' . "\n";
        }
    }
    $ret .= '</tr>' . "\n" . '</tbody>' . "\n" . '</table>' . "\n";
    if ($today_view) {
        $ret .= '</div>' . "\n";
        // カレンダーのdivタグを閉じる
        $ret .= '<section class="style_calendar_post">' . "\n";
        if ($today_args == '') {
            $str = '<article id="' . $tpage . '" class="style_calendar_post">' . "\n";
            $tpage = $prefix . sprintf(PLUGIN_CALENDAR_PANENAME_FORMAT, $today['year'], $today['mon'], $today['mday']);
            $t_wiki = Factory::Wiki($tpage);
            if ($t_wiki->has()) {
                $_page = $vars['page'];
                $get['page'] = $post['page'] = $vars['page'] = $tpage;
                preg_replace('/^#navi/', '/\\/\\/#navi/', $source);
                $str .= $t_wiki->render();
                $str .= '<hr /><a href="' . $t_wiki->uri('edit', $tpage) . '">' . $_calendar_msg['_edit'] . '</a>';
                $get['page'] = $post['page'] = $vars['page'] = $_page;
            } else {
                $str .= sprintf($_calendar_msg['_empty'], make_pagelink($prefix . sprintf(PLUGIN_CALENDAR_PANENAME_FORMAT, $today['year'], $today['mon'], $today['mday'])));
            }
            $str .= '</article>' . "\n";
        } else {
            $aryargs = array(rawurldecode($base), $page_YM, $today_args);
            if (exist_plugin('calendar_viewer')) {
                T_bindtextdomain('calendar_viewer', LANG_DIR);
                T_textdomain('calendar_viewer');
                $str = call_user_func_array('plugin_calendar_viewer_convert', $aryargs);
                T_textdomain('calendar');
            }
        }
        $ret .= $str . "\n";
        $ret .= '</section>' . "\n";
        $ret .= '</div>' . "\n";
    }
    return $ret;
}
Example #6
0
function plugin_referer_body($data)
{
    global $_referer_msg;
    global $referer;
    $config_referer = plugin_referer_get_config();
    // 構成定義ファイル読込
    $IgnoreHost = array_merge($config_referer['spam'], $config_referer['misc']);
    $sort_last = '0d';
    $sort_1st = '1d';
    $sort_ctr = '2d';
    usort($data, function ($a, $b) {
        return $b[0] - $a[0];
    });
    $arrow_last = $_referer_msg['msg_Chr_darr'];
    $sort_last = '0a';
    $body = array();
    $body[] = '<table summary="Referer" class="table table-bordered referer_table" data-pagenate="true">';
    $body[] = '<thead>';
    $body[] = '<tr>';
    $body[] = '<th>' . $_referer_msg['msg_Hed_LastUpdate'] . '</th>';
    $body[] = '<th>' . $_referer_msg['msg_Hed_1stDate'] . '</th>';
    $body[] = '<th style="text-align:right">' . $_referer_msg['msg_Hed_RefCounter'] . '</th>';
    $body[] = '<th>' . $_referer_msg['msg_Hed_Referer'] . '</th>';
    $body[] = '</tr>';
    $body[] = '</thead>';
    $body[] = '<tbody>';
    $ctr = 0;
    foreach ($data as $x) {
        // 'scheme', 'host', 'port', 'user', 'pass', 'path', 'query', 'fragment'
        // 0:最終更新日時, 1:初回登録日時, 2:参照カウンタ, 3:Referer ヘッダ, 4:利用可否フラグ(1は有効)
        list($ltime, $stime, $count, $url) = $x;
        $uri = isset($url) ? parse_url($url) : null;
        if (strpos($uri['host'], '.') == '') {
            continue;
        }
        // ホスト名にピリオドが1つもない
        if (plugin_referer_ignore_check($uri['host'])) {
            continue;
        }
        $sw = 0;
        foreach ($IgnoreHost as $y) {
            if (strpos($uri['host'], $y) !== FALSE) {
                $sw = 1;
                continue;
            }
        }
        if ($sw) {
            continue;
        }
        if ($count < 0) {
            continue;
        }
        // 項目不正の場合の対応
        // カウンタが数値ではない場合は、表示を抑止
        if (!is_numeric($count)) {
            continue;
        }
        $sw_ignore = plugin_referer_ignore_check($url);
        if ($sw_ignore && $referer > 1) {
            continue;
        }
        // 非ASCIIキャラクタ(だけ)をURLエンコードしておく BugTrack/440
        //$e_url = htmlsc(preg_replace('/([" \x80-\xff]+)/e', 'rawurlencode("$1")', $url));
        $e_url = preg_replace_callback('([" \\x80-\\xff]+)', function ($m) {
            return isset($m[1]) ? rawurlencode($m[1]) : null;
        }, $url);
        $s_url = mb_convert_encoding(rawurldecode($url), SOURCE_ENCODING);
        $s_url = Utility::htmlsc(mb_strimwidth($s_url, 0, REFERE_TITLE_LENGTH, '...'));
        $lpass = Time::passage($ltime);
        // 最終更新日時からの経過時間
        $spass = Time::passage($stime);
        // 初回登録日時からの経過時間
        $ldate = Time::getZoneTimeDate($_referer_msg['msg_Fmt_Date'], $ltime);
        // 最終更新日時文字列
        $sdate = Time::getZoneTimeDate($_referer_msg['msg_Fmt_Date'], $stime);
        // 初回登録日時文字列
        $body[] = '<tr>';
        $body[] = '<td>' . $ldate . ' (' . $lpass . ')</td>';
        $body[] = $count == 1 ? '<td>N/A</td>' : '<td>' . $sdate . ' (' . $spass . ')</td>';
        $body[] = '<td style="text-align:right;">' . $count . '</td>';
        // 適用不可データのときはアンカーをつけない
        $body[] = $sw_ignore ? '<td>' . $s_url . '</td>' : '<td><a href="' . $e_url . '" rel="nofollow noreferer external">' . $s_url . '</a></td>';
        $body[] = '</tr>';
        $ctr++;
    }
    $body[] = '</tbody>';
    $body[] = '</table>';
    if ($ctr === 0) {
        return '<p class="alert alert-warning">' . $_referer_msg['msg_no_data'] . '</p>';
    }
    return join("\n", $body);
}