function plugin_epoch_inline() { $value = func_get_args(); $args = func_num_args(); if ($args > 3) { return '&epoch(utime[,class]);'; } $array = explode(',', $value[0]); $format = Time::format($array[0]); $passaage = Time::passage($array[0]); $class = !empty($array[1]) ? $array[1] : 'epoch'; $ret = '<time datetime="' . get_date('c', $value[0]) . '" class="' . $class . '" title="' . $passaage . '">' . $format . '</time>'; if (!empty($value[1])) { $erapse = MUTIME - $value[0]; if ($erapse < 432000) { $ret .= ' <span class="'; if ($erapse < 86400) { $ret .= 'new1'; } else { $ret .= 'new5'; } $ret .= '">New</span>'; } } return $ret; }
function get_passage($time, $paren = TRUE) { $time = Time::passage($time); return $paren ? '(' . $time . ')' : $time; }
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); }
/** * ファイルの経過時間を取得 * @return string */ public function passage() { return Time::passage($this->time()); }
function format_cell($timestamp) { return Time::passage($timestamp, FALSE); }