示例#1
0
function PN_Referer_Default()
{
    global $pluginMenuURL, $pluginSelfParam;
    if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['page'])) {
        $_GET['page'] = $_POST['page'];
    }
    $page = Setting::getBlogSetting('RowsPerPageReferer', 20);
    if (empty($_POST['perPage'])) {
        $perPage = $page;
    } else {
        if ($page != $_POST['perPage']) {
            Setting::setBlogSetting('RowsPerPageReferer', $_POST['perPage']);
            $perPage = $_POST['perPage'];
        } else {
            $perPage = $_POST['perPage'];
        }
    }
    ?>
						<div id="part-statistics-rank" class="part">
							<h2 class="caption"><span class="main-text"><?php 
    echo _t("리퍼러 순위");
    ?>
</span></h2>
							
							<table class="data-inbox" cellspacing="0" cellpadding="0">
								<thead>
									<tr>
										<th class="number"><span class="text"><?php 
    echo _t("순위");
    ?>
</span></th>
										<th class="site"><span class="text"><?php 
    echo _t("리퍼러");
    ?>
</span></th>
									</tr>
								</thead>
								<tbody>
<?php 
    $temp = Statistics::getRefererStatistics(getBlogId());
    for ($i = 0; $i < count($temp); $i++) {
        $record = $temp[$i];
        $className = $i % 2 == 1 ? 'even-line' : 'odd-line';
        $className .= $i == sizeof($temp) - 1 ? ' last-line' : '';
        ?>
									<tr class="<?php 
        echo $className;
        ?>
 inactive-class" onmouseover="rolloverClass(this, 'over')" onmouseout="rolloverClass(this, 'out')">
										<td class="rank"><?php 
        echo $i + 1;
        ?>
.</td>
										<td class="site"><a href="http://<?php 
        echo Utils_Misc::escapeJSInAttribute($record['host']);
        ?>
" onclick="window.open(this.href); return false;"><?php 
        echo htmlspecialchars($record['host']);
        ?>
</a> <span class="count">(<?php 
        echo $record['count'];
        ?>
)</span></td>
									</tr>
<?php 
    }
    ?>
								</tbody>
							</table>
						</div>
						
						<hr class="hidden" />
						
						<form id="part-statistics-log" class="part" method="post" action="<?php 
    echo $pluginMenuURL;
    ?>
">
							<h2 class="caption"><span class="main-text"><?php 
    echo _t("리퍼러 로그");
    ?>
</span></h2>
							
							<table class="data-inbox" cellspacing="0" cellpadding="0">
								<thead>
									<tr>
										<th class="number"><span class="text">날짜</span></th>
										<th class="site"><span class="text">주소</span></th>
									</tr>
								</thead>
								<tbody>
<?php 
    $more = false;
    list($referers, $paging) = Statistics::getRefererLogsWithPage($_GET['page'], $perPage);
    for ($i = 0; $i < count($referers); $i++) {
        $record = $referers[$i];
        $className = $i % 2 == 1 ? 'even-line' : 'odd-line';
        $className .= $i == sizeof($referers) - 1 ? ' last-line' : '';
        ?>
									<tr class="<?php 
        echo $className;
        ?>
 inactive-class" onmouseover="rolloverClass(this, 'over')" onmouseout="rolloverClass(this, 'out')">
										<td class="date"><?php 
        echo Timestamp::formatDate($record['referred']);
        ?>
</td>
										<td class="address"><a href="<?php 
        echo Utils_Misc::escapeJSInAttribute($record['url']);
        ?>
" onclick="window.open(this.href); return false;" title="<?php 
        echo htmlspecialchars($record['url']);
        ?>
"><?php 
        echo fireEvent('ViewRefererURL', htmlspecialchars(Utils_Unicode::lessenAsEm($record['url'], 70)), $record);
        ?>
</a></td>
									</tr>
<?php 
    }
    ?>
								</tbody>
							</table>
							
							<div class="data-subbox">
								<div id="page-section" class="section">
									<div id="page-navigation">
										<span id="page-list">
<?php 
    $paging['prefix'] = $pluginSelfParam . '&page=';
    $pagingTemplate = '[##_paging_rep_##]';
    $pagingItemTemplate = '<a [##_paging_rep_link_##]>[[##_paging_rep_link_num_##]]</a>';
    echo str_repeat("\t", 8) . Paging::getPagingView($paging, $pagingTemplate, $pagingItemTemplate) . CRLF;
    ?>
										</span>
									</div>
									<div class="page-count">
										<?php 
    echo Utils_Misc::getArrayValue(explode('%1', '한 페이지에 목록 %1건 표시'), 0);
    ?>
										<select name="perPage" onchange="document.getElementById('part-statistics-log').submit()">					
<?php 
    for ($i = 10; $i <= 30; $i += 5) {
        if ($i == $perPage) {
            ?>
											<option value="<?php 
            echo $i;
            ?>
" selected="selected"><?php 
            echo $i;
            ?>
</option>
<?php 
        } else {
            ?>
											<option value="<?php 
            echo $i;
            ?>
"><?php 
            echo $i;
            ?>
</option>
<?php 
        }
    }
    ?>
										</select>
										<?php 
    echo Utils_Misc::getArrayValue(explode('%1', '한 페이지에 목록 %1건 표시'), 1);
    ?>
									</div>
								</div>
							</div>
						</form>
						
						<div class="clear"></div>
<?php 
}
示例#2
0
function refererkeyword()
{
    $context = Model_Context::getInstance();
    $data = $context->getProperty('plugin.config');
    $showURL = 0;
    $limitRank = 5;
    $Filtering = array();
    if (!is_null($data)) {
        $showURL = $data['showURL'];
        $limitRank = $data['limitRank'];
        $Filtering = preg_split("/[\\s,]+/", $data['WordFiltering']);
    }
    if (!empty($_POST['showURL'])) {
        $showURL = $_POST['showURL'];
    }
    if (!empty($_POST['showKeywordlistLight'])) {
        $limitRank = $_POST['showKeywordlistLight'];
    }
    $refereres = Statistics::getRefererLogs();
    $keywordlist = array();
    $wordlist = array();
    $record = array();
    $refererURL = array();
    $totalpassedkeyword = 0;
    for ($i = 0; $i < sizeof($refereres); $i++) {
        $record = $refereres[$i];
        if ($i == 0) {
            $referredend = $record['referred'];
        }
        $keyword = "";
        $passthiskeyword = 0;
        list($keyword, ) = bringSearchWord($record['url'], $record['host']);
        foreach ($Filtering as $FilterWord) {
            if (strpos($keyword, $FilterWord) !== false) {
                $passthiskeyword = 1;
                $totalpassedkeyword++;
                break 1;
            }
        }
        if ($passthiskeyword == 0) {
            if (array_key_exists($keyword, $keywordlist)) {
                $refererURL[$keyword][$keywordlist[$keyword]] = $record['url'];
                $keywordlist[$keyword]++;
            } elseif ($keyword) {
                $keywordlist[$keyword] = 1;
                $refererURL[$keyword][0] = $record['url'];
            }
            $word = explode(" ", $keyword);
            foreach ($word as $maira) {
                if (array_key_exists($maira, $wordlist)) {
                    $wordlist[$maira]++;
                } elseif ($maira) {
                    $wordlist[$maira] = 1;
                }
            }
        }
    }
    $referredstart = array_key_exists('referred', $record) ? $record['referred'] : null;
    ?>
    <h2 class="caption"><span
            class="main-text"><?php 
    echo _t('리퍼러 검색어 통계') . " (" . Timestamp::formatDate($referredstart) . " ~ " . Timestamp::formatDate($referredend) . ")";
    ?>
</span>
    </h2>

    <div id="statistics-counter-inbox" class="data-inbox">
        <div class="title">
            <span class="label"><span class="text"><?php 
    echo _t('총 검색어 개수');
    ?>
</span></span>
            <span class="divider"> : </span>
            <span id="total"><?php 
    echo count($keywordlist);
    ?>
</span>
            <span class="divider"> : </span>
            <span class="label"><span class="text"><?php 
    echo _t('총 리퍼러 개수');
    ?>
</span></span>
            <span class="divider"> : </span>
            <span id="total"><?php 
    echo sizeof($refereres);
    ?>
</span>
            <span class="divider"> : </span>
            <?php 
    if ($totalpassedkeyword > 0) {
        ?>
                <span class="label"><span class="text"><?php 
        echo _t('필터링된 리퍼러 개수');
        ?>
</span></span>
                <span class="divider"> : </span>
                <span id="total"><?php 
        echo $totalpassedkeyword;
        ?>
</span>
                <span class="divider"> : </span>
            <?php 
    }
    ?>
        </div>
        <form id="refererkeyword-option" class="part" method="post" action="<?php 
    echo $context->getProperty('plugin.uri.menu');
    ?>
">
            <div class="title">
                <span class="label"><?php 
    echo _t('검색어 순위 출력은');
    ?>
</span>
										<span class="label"><select name="showKeywordlistLight"
                                                                    onchange="document.getElementById('refererkeyword-option').submit()">
                                                <option
                                                    value="5"<?php 
    if ($limitRank == 5 || $limitRank == 0) {
        echo " selected=\"selected\"";
    }
    ?>
><?php 
    echo _t('5위까지만 출력합니다');
    ?>
</option>
                                                <option
                                                    value="10"<?php 
    if ($limitRank == 10) {
        echo " selected=\"selected\"";
    }
    ?>
><?php 
    echo _t('10위까지만 출력합니다');
    ?>
</option>
                                                <option
                                                    value="15"<?php 
    if ($limitRank == 15) {
        echo " selected=\"selected\"";
    }
    ?>
><?php 
    echo _t('15위까지만 출력합니다');
    ?>
</option>
                                                <option
                                                    value="3939"<?php 
    if ($limitRank == 3939) {
        echo " selected=\"selected\"";
    }
    ?>
><?php 
    echo _t('모든 순위를 출력합니다');
    ?>
</option>
                                            </select></span>
            </div>
            <div class="title">
                <span class="label"><span class="text"><?php 
    echo _t('각 검색어가 검출된 주소를');
    ?>
</span></span>
										<span class="label"><select name="showURL"
                                                                    onchange="document.getElementById('refererkeyword-option').submit()">
                                                <option
                                                    value="0"<?php 
    if ($showURL == 0 || $showURL == "") {
        echo " selected=\"selected\"";
    }
    ?>
><?php 
    echo _t('출력하지 않습니다');
    ?>
</option>
                                                <option
                                                    value="1"<?php 
    if ($showURL == 1) {
        echo " selected=\"selected\"";
    }
    ?>
><?php 
    echo _t('출력합니다');
    ?>
</option>
                                            </select></span>

            </div>
        </form>
    </div>

    <hr class="hidden"/>

    <div id="part-statistics-cloud" class="part">
        <table class="data-inbox" cellspacing="0" cellpadding="0">
            <thead>
            <tr>
                <th class="site"><span class="text"><?php 
    echo _t('검색어에 주로 쓰인 단어');
    ?>
</span></th>
            </tr>
            </thead>
            <tbody>
            <tr class="even-line inactive-class">
                <td class="keywordcloud">
                    <?php 
    srand((double) microtime() * 1000000);
    $wordlist = array_sort($wordlist, 'desc');
    $original_wordlist = $wordlist;
    $wordkeys = array_keys($wordlist);
    $i = 0;
    $cloudstyle = array();
    foreach ($wordkeys as $wordwork) {
        if ($wordlist[$wordwork] < 2) {
            unset($wordlist[$wordwork]);
            unset($wordkeys[$i]);
            $cloudstyle[$i] = "cloud5";
            $i++;
            continue;
        }
        if ($wordlist[$wordwork] > 50) {
            $cloudstyle[$i] = "cloud1";
        } elseif ($wordlist[$wordwork] > 25) {
            $cloudstyle[$i] = "cloud2";
        } elseif ($wordlist[$wordwork] > 15) {
            $cloudstyle[$i] = "cloud3";
        } elseif ($wordlist[$wordwork] > 6) {
            $cloudstyle[$i] = "cloud4";
        } else {
            $cloudstyle[$i] = "cloud5";
        }
        $i++;
    }
    if (count($wordkeys) <= 10) {
        $wordlist = $original_wordlist;
        $wordkeys = array_keys($wordlist);
    }
    //shuffle ($wordkeys);
    $beforewordvalue = '';
    $wordrank = 0;
    for ($i = 0; $i < sizeof($wordlist); $i++) {
        $wordkey = $wordkeys[$i];
        $wordvalue = $wordlist[$wordkey];
        $wordkey = str_replace("\"", "&quot;", $wordkeys[$i]);
        if ($wordvalue != $beforewordvalue) {
            if ($wordrank == 15) {
                break;
            }
            $wordrank++;
            $beforewordvalue = $wordvalue;
        }
        $wordclassName = $i % 2 == 1 ? 'even-line' : 'odd-line';
        $wordclassName .= $i == sizeof($wordlist) - 1 ? ' last-line' : '';
        echo "<a class=\"" . $cloudstyle[$i] . "\">" . htmlspecialchars($wordkey) . "</a>&nbsp;&nbsp;";
    }
    ?>
                </td>
            </tr>
            </tbody>
        </table>
    </div>

    <hr class="hidden"/>


    <div id="part-statistics-log" class="part">
        <table class="data-inbox" cellspacing="0" cellpadding="0">
            <thead>
            <tr>
                <th class="number"><span class="text"><?php 
    echo _t('순위');
    ?>
</span></th>
                <th class="number"><span class="text"><?php 
    echo _t('개수');
    ?>
</span></th>
                <th class="searchwordtitle"><span class="text"><?php 
    echo _t('검색어명');
    ?>
</span></th>
            </tr>
            </thead>
            <tbody>
            <?php 
    $keywordlist = array_sort($keywordlist, 'desc');
    $keywordkeys = array_keys($keywordlist);
    $beforekeywordvalue = '';
    $rank = array();
    $samerank = 1;
    $rankcount = 0;
    // 머리가 나빠서 죄송합니다... orz
    for ($i = 0; $i < sizeof($keywordlist); $i++) {
        $keywordkey = $keywordkeys[$i];
        $keywordvalue = $keywordlist[$keywordkey];
        //	$keywordkey = str_replace("\"", "&quot;",$keywordkeys[$i]);
        if ($keywordvalue != $beforekeywordvalue) {
            $rankcount++;
            $rank[$i] = $rankcount;
            $beforekeywordvalue = $keywordvalue;
        } else {
            $rank[$i] = $rankcount;
        }
    }
    $eversamerankTotal = array_count_values($rank);
    $rankcount = 0;
    for ($i = 0; $i < sizeof($keywordlist); $i++) {
        $keywordkey = $keywordkeys[$i];
        $keywordvalue = $keywordlist[$keywordkey];
        //	$keywordkey = str_replace("\"", "&quot;",$keywordkeys[$i]);
        if ($keywordvalue != $beforekeywordvalue) {
            $rankcount++;
            $beforekeywordvalue = $keywordvalue;
            $samerank = 1;
        } else {
            $samerank++;
        }
        if ($limitRank != 3939) {
            if ($rankcount >= 6 && $limitRank == 5) {
                break;
            }
            if ($rankcount >= 11 && $limitRank == 10) {
                break;
            }
            if ($rankcount >= 16 && $limitRank == 15) {
                break;
            }
        }
        $RefererURLthiskeyword = $refererURL[$keywordkey];
        if ($eversamerankTotal[$rankcount] == 1) {
            $viewSameRank = '';
        } else {
            $viewSameRank = " (" . $samerank . "/" . $eversamerankTotal[$rankcount] . ")";
        }
        ?>
                <tr onmouseover="rolloverClass(this, 'over')" onmouseout="rolloverClass(this, 'out')">
                    <td class="rank"><?php 
        echo $rankcount . _t('위') . $viewSameRank;
        ?>
</td>
                    <td class="rank"><?php 
        echo $keywordvalue . _t('개');
        ?>
</td>
                    <td class="address"><?php 
        echo htmlspecialchars($keywordkey);
        ?>
</td>
                </tr>
                <?php 
        if ($showURL == 1) {
            $j = 0;
            foreach (array_unique($RefererURLthiskeyword) as $splitRefererURL) {
                $urlClassName = $j == sizeof(array_unique($RefererURLthiskeyword)) - 1 ? '' : 'noBorderBottom';
                list(, $decodeURL) = bringSearchWord($splitRefererURL);
                ?>
                        <tr>
                        <td class="<?php 
                echo $urlClassName;
                ?>
"></td>
                        <td class="<?php 
                echo $urlClassName;
                ?>
"></td>
                        <td class="refererurl">
                        <?php 
                echo "<a href=\"" . Utils_Misc::escapeJSInAttribute($splitRefererURL) . "\" onclick=\"window.open(this.href); return false;\">" . Utils_Unicode::lessenAsEm(htmlspecialchars($decodeURL), 90) . "</a>";
                $j++;
            }
        }
        ?>
                </td>
                </tr>
            <?php 
    }
    ?>
            </tbody>
        </table>
    </div>
    <div class="clear"></div>
<?php 
}