Exemplo n.º 1
0
function plugin_referer_body($page, $sort)
{
    global $script;
    $qm = get_qm();
    $data = tb_get(tb_get_filename($page, '.ref'));
    if (empty($data)) {
        return '<p>no data.</p>';
    }
    $bg = plugin_referer_set_color();
    $arrow_last = $arrow_1st = $arrow_ctr = '';
    $color_last = $color_1st = $color_ctr = $color_ref = $bg['etc'];
    $sort_last = '0d';
    $sort_1st = '1d';
    $sort_ctr = '2d';
    switch ($sort) {
        case '0d':
            // 0d 最終更新日時(新着順)
            usort($data, create_function('$a,$b', 'return $b[0] - $a[0];'));
            $color_last = $bg['cur'];
            $arrow_last = $qm->m['plg_referer']['down'];
            $sort_last = '0a';
            break;
        case '0a':
            // 0a 最終更新日時(日付順)
            usort($data, create_function('$a,$b', 'return $a[0] - $b[0];'));
            $color_last = $bg['cur'];
            $arrow_last = $qm->m['plg_referer']['up'];
            //		$sort_last = '0d';
            break;
        case '1d':
            // 1d 初回登録日時(新着順)
            usort($data, create_function('$a,$b', 'return $b[1] - $a[1];'));
            $color_1st = $bg['cur'];
            $arrow_1st = $qm->m['plg_referer']['down'];
            $sort_1st = '1a';
            break;
        case '1a':
            // 1a 初回登録日時(日付順)
            usort($data, create_function('$a,$b', 'return $a[1] - $b[1];'));
            $color_1st = $bg['cur'];
            $arrow_1st = $qm->m['plg_referer']['up'];
            //		$sort_1st = '1d';
            break;
        case '2d':
            // 2d カウンタ(大きい順)
            usort($data, create_function('$a,$b', 'return $b[2] - $a[2];'));
            $color_ctr = $bg['cur'];
            $arrow_ctr = $qm->m['plg_referer']['down'];
            $sort_ctr = '2a';
            break;
        case '2a':
            // 2a カウンタ(小さい順)
            usort($data, create_function('$a,$b', 'return $a[2] - $b[2];'));
            $color_ctr = $bg['cur'];
            $arrow_ctr = $qm->m['plg_referer']['up'];
            //		$sort_ctr = '2d';
            break;
        case '3':
            // 3 Referer
            usort($data, create_function('$a,$b', 'return ($a[3] == $b[3]) ? 0 : (($a[3] > $b[3]) ? 1 : -1);'));
            $color_ref = $bg['cur'];
            break;
    }
    $body = '';
    foreach ($data as $arr) {
        // 0:最終更新日時, 1:初回登録日時, 2:参照カウンタ, 3:Referer ヘッダ, 4:利用可否フラグ(1は有効)
        list($ltime, $stime, $count, $url, $enable) = $arr;
        // 非ASCIIキャラクタ(だけ)をURLエンコードしておく BugTrack/440
        $e_url = htmlspecialchars(preg_replace('/([" \\x80-\\xff]+)/e', 'rawurlencode("$1")', $url));
        $s_url = htmlspecialchars(mb_convert_encoding(rawurldecode($url), SOURCE_ENCODING, 'auto'));
        $lpass = get_passage($ltime, FALSE);
        // 最終更新日時からの経過時間
        $spass = get_passage($stime, FALSE);
        // 初回登録日時からの経過時間
        $ldate = get_date($qm->m['plg_referer']['date_format'], $ltime);
        // 最終更新日時文字列
        $sdate = get_date($qm->m['plg_referer']['date_format'], $stime);
        // 初回登録日時文字列
        $body .= ' <tr>' . "\n" . '  <td>' . $ldate . '</td>' . "\n" . '  <td>' . $lpass . '</td>' . "\n";
        $body .= $count == 1 ? '  <td colspan="2">N/A</td>' . "\n" : '  <td>' . $sdate . '</td>' . "\n" . '  <td>' . $spass . '</td>' . "\n";
        $body .= '  <td style="text-align:right;">' . $count . '</td>' . "\n";
        // 適用不可データのときはアンカーをつけない
        $body .= plugin_referer_ignore_check($url) ? '  <td>' . $s_url . '</td>' . "\n" : '  <td><a href="' . $e_url . '" rel="nofollow">' . $s_url . '</a></td>' . "\n";
        $body .= ' </tr>' . "\n";
    }
    $href = $script . '?plugin=referer&amp;page=' . rawurlencode($page);
    return <<<EOD
<table border="1" cellspacing="1" summary="Referer">
 <tr>
  <td style="background-color:{$color_last}" colspan="2">
   <a href="{$href}&amp;sort={$sort_last}">{$qm->m['plg_referer']['lastupdate']}{$arrow_last}</a>
  </td>
  <td style="background-color:{$color_1st}" colspan="2">
   <a href="{$href}&amp;sort={$sort_1st}">{$qm->m['plg_referer']['firstdate']}{$arrow_1st}</a>
  </td>
  <td style="background-color:{$color_ctr};text-align:right">
   <a href="{$href}&amp;sort={$sort_ctr}">{$qm->m['plg_referer']['counter']}{$arrow_ctr}</a>
  </td>
  <td style="background-color:{$color_ref}">
   <a href="{$href}&amp;sort=3">{$qm->m['plg_referer']['referer']}</a>
   </td>
 </tr>
 {$body}
</table>
EOD;
}
Exemplo n.º 2
0
function plugin_referer_body($page, $sort)
{
    global $script, $_referer_msg;
    global $referer;
    $data = tb_get(tb_get_filename($page, '.ref'));
    if (empty($data)) {
        return '<p>no data.</p>';
    }
    $bg = plugin_referer_set_color();
    $arrow_last = $arrow_1st = $arrow_ctr = '';
    $color_last = $color_1st = $color_ctr = $color_ref = $bg['etc'];
    $sort_last = '0d';
    $sort_1st = '1d';
    $sort_ctr = '2d';
    switch ($sort) {
        case '0d':
            // 0d 最終更新日時(新着順)
            usort($data, create_function('$a,$b', 'return $b[0] - $a[0];'));
            $color_last = $bg['cur'];
            $arrow_last = $_referer_msg['msg_Chr_darr'];
            $sort_last = '0a';
            break;
        case '0a':
            // 0a 最終更新日時(日付順)
            usort($data, create_function('$a,$b', 'return $a[0] - $b[0];'));
            $color_last = $bg['cur'];
            $arrow_last = $_referer_msg['msg_Chr_uarr'];
            //		$sort_last = '0d';
            break;
        case '1d':
            // 1d 初回登録日時(新着順)
            usort($data, create_function('$a,$b', 'return $b[1] - $a[1];'));
            $color_1st = $bg['cur'];
            $arrow_1st = $_referer_msg['msg_Chr_darr'];
            $sort_1st = '1a';
            break;
        case '1a':
            // 1a 初回登録日時(日付順)
            usort($data, create_function('$a,$b', 'return $a[1] - $b[1];'));
            $color_1st = $bg['cur'];
            $arrow_1st = $_referer_msg['msg_Chr_uarr'];
            //		$sort_1st = '1d';
            break;
        case '2d':
            // 2d カウンタ(大きい順)
            usort($data, create_function('$a,$b', 'return $b[2] - $a[2];'));
            $color_ctr = $bg['cur'];
            $arrow_ctr = $_referer_msg['msg_Chr_darr'];
            $sort_ctr = '2a';
            break;
        case '2a':
            // 2a カウンタ(小さい順)
            usort($data, create_function('$a,$b', 'return $a[2] - $b[2];'));
            $color_ctr = $bg['cur'];
            $arrow_ctr = $_referer_msg['msg_Chr_uarr'];
            //		$sort_ctr = '2d';
            break;
        case '3':
            // 3 Referer
            usort($data, create_function('$a,$b', 'return ($a[3] == $b[3]) ? 0 : (($a[3] > $b[3]) ? 1 : -1);'));
            $color_ref = $bg['cur'];
            break;
    }
    $body = '';
    $ctr = 0;
    foreach ($data as $arr) {
        // 0:最終更新日時, 1:初回登録日時, 2:参照カウンタ, 3:Referer ヘッダ, 4:利用可否フラグ(1は有効)
        list($ltime, $stime, $count, $url, $enable) = $arr;
        // 項目不正の場合の対応
        // カウンタが数値ではない場合は、表示を抑止
        if (!is_numeric($count)) {
            continue;
        }
        $sw_ignore = plugin_referer_ignore_check($url);
        if ($sw_ignore && $referer > 1) {
            continue;
        }
        // 非ASCIIキャラクタ(だけ)をURLエンコードしておく BugTrack/440
        $e_url = htmlspecialchars(preg_replace('/([" \\x80-\\xff]+)/e', 'rawurlencode("$1")', $url));
        $s_url = htmlspecialchars(mb_convert_encoding(rawurldecode($url), SOURCE_ENCODING, 'auto'));
        $s_url = mb_strimwidth($s_url, 0, REFERE_TITLE_LENGTH, '...');
        $lpass = get_passage($ltime, FALSE);
        // 最終更新日時からの経過時間
        $spass = get_passage($stime, FALSE);
        // 初回登録日時からの経過時間
        $ldate = get_date($_referer_msg['msg_Fmt_Date'], $ltime);
        // 最終更新日時文字列
        $sdate = get_date($_referer_msg['msg_Fmt_Date'], $stime);
        // 初回登録日時文字列
        $body .= ' <tr>' . "\n" . '  <td>' . $ldate . '</td>' . "\n" . '  <td>' . $lpass . '</td>' . "\n";
        $body .= $count == 1 ? '  <td colspan="2">N/A</td>' . "\n" : '  <td>' . $sdate . '</td>' . "\n" . '  <td>' . $spass . '</td>' . "\n";
        $body .= '  <td style="text-align:right;">' . $count . '</td>' . "\n";
        // 適用不可データのときはアンカーをつけない
        $body .= $sw_ignore ? '  <td>' . $s_url . '</td>' . "\n" : '  <td><a href="' . $e_url . '" rel="nofollow">' . $s_url . '</a></td>' . "\n";
        $body .= ' </tr>' . "\n";
        $ctr++;
    }
    if ($ctr === 0) {
        return '<p>no data.</p>';
    }
    $href = $script . '?plugin=referer&amp;page=' . rawurlencode($page);
    return <<<EOD
<table border="1" cellspacing="1" summary="Referer">
 <tr>
  <td style="background-color:{$color_last}" colspan="2">
   <a href="{$href}&amp;sort={$sort_last}">{$_referer_msg['msg_Hed_LastUpdate']}{$arrow_last}</a>
  </td>
  <td style="background-color:{$color_1st}" colspan="2">
   <a href="{$href}&amp;sort={$sort_1st}">{$_referer_msg['msg_Hed_1stDate']}{$arrow_1st}</a>
  </td>
  <td style="background-color:{$color_ctr};text-align:right">
   <a href="{$href}&amp;sort={$sort_ctr}">{$_referer_msg['msg_Hed_RefCounter']}{$arrow_ctr}</a>
  </td>
  <td style="background-color:{$color_ref}">
   <a href="{$href}&amp;sort=3">{$_referer_msg['msg_Hed_Referer']}</a>
   </td>
 </tr>
 {$body}
</table>
EOD;
}
Exemplo n.º 3
0
function linklist_analysis($data)
{
    $config_referer = plugin_referer_get_config();
    // 構成定義ファイル読込
    $IgnoreHost = array_merge($config_referer['spam'], $config_referer['misc']);
    $rc = array();
    $i = 0;
    // 自サイトの特定
    $my = parse_url(get_script_uri());
    $my = $my['host'];
    // 0:最終更新日時 1:初回登録日時 2:参照カウンタ 3:Referer ヘッダ 4:利用可否フラグ(1は有効)
    foreach ($data as $x) {
        if (isset($x[4]) && $x[4] === 1) {
            continue;
        }
        // 'scheme', 'host', 'port', 'user', 'pass', 'path', 'query', 'fragment'
        $url = isset($x[3]) ? parse_url($x[3]) : null;
        if (empty($url['host'])) {
            continue;
        }
        if (strpos($url['host'], '.') == '') {
            continue;
        }
        // ホスト名にピリオドが1つもない
        if (plugin_referer_ignore_check($url['host'])) {
            continue;
        }
        $sw = 0;
        foreach ($IgnoreHost as $y) {
            if (strpos($url['host'], $y) !== FALSE) {
                $sw = 1;
                continue;
            }
        }
        if ($sw) {
            continue;
        }
        if (strpos($url['host'], $my) !== FALSE) {
            continue;
        }
        $sw = 0;
        // queryストリングの解析
        if (isset($url['query'])) {
            $tok = strtok($url['query'], '&');
            if (is_array($tok)) {
                while ($tok) {
                    list($key, $parm) = preg_split('/=/', $tok);
                    // キーと値に分割
                    $tok = strtok('&');
                    // 次の処理の準備
                    // 検索キーかの判定
                    $skey = '';
                    foreach ($config_referer['key'] as $y) {
                        if (strpos($key, $y[0]) === 0) {
                            $skey = $y[0];
                            continue;
                        }
                    }
                    if ($skey !== $key) {
                        continue;
                    }
                    if (empty($parm)) {
                        continue;
                    }
                    // 値が入っていない場合
                    // 検索エンジンからきたもの
                    $sw = 1;
                    break;
                }
            }
        }
        // 検索エンジン以外 かつ 架空ホスト以外 の場合は蓄積
        // if (!$sw and linklist_testipaddress($url['host']) )
        // 検索エンジン以外の場合は蓄積
        if (!$sw) {
            $rc[$i][0] = $x[3];
            // 3:Referer ヘッダ
            $rc[$i][1] = $x[2];
            // 参照カウンタ
            $i++;
        }
    }
    return $rc;
}