Beispiel #1
0
function counterize_show_history($frompage = "counterize_dashboard", $directcall = false)
{
    global $wpdb;
    if ($directcall) {
        if (!counterize_getamount()) {
            _e("There's no data in the database - You can't see stats until you have data.", COUNTERIZE_TD);
            return;
        }
    }
    $howmany = __('Latest entries', COUNTERIZE_TD);
    $amount = counterize_get_option('amount');
    if ($amount == '' || $amount == ' ') {
        $amount = 50;
    }
    $howmany = "{$howmany} ‪({$amount})‬";
    $url = "admin.php?page={$frompage}";
    //check if ipfilter is set
    if (!empty($_POST['ipfilter'])) {
        $ipfilter = htmlspecialchars($_POST['ipfilter']);
    } elseif (!empty($_GET['ipfilter'])) {
        $ipfilter = htmlspecialchars($_GET['ipfilter']);
    }
    //check if countryfilter is set
    if (!empty($_POST['countryfilter'])) {
        $countryfilter = htmlspecialchars($_POST['countryfilter']);
    } elseif (!empty($_GET['countryfilter'])) {
        $countryfilter = htmlspecialchars($_GET['countryfilter']);
    }
    //check if urifilter is set
    if (!empty($_POST['urifilter'])) {
        $urifilter = htmlspecialchars($_POST['urifilter']);
    } elseif (!empty($_GET['urifilter'])) {
        $urifilter = htmlspecialchars($_GET['urifilter']);
    }
    //check if refererfilter is set
    if (!empty($_POST['refererfilter'])) {
        $refererfilter = htmlspecialchars($_POST['refererfilter']);
    } elseif (!empty($_GET['refererfilter'])) {
        $refererfilter = htmlspecialchars($_GET['refererfilter']);
    }
    //check if agentfilter is set
    if (!empty($_POST['agentfilter'])) {
        $agentfilter = htmlspecialchars($_POST['agentfilter']);
    } elseif (!empty($_GET['agentfilter'])) {
        $agentfilter = htmlspecialchars($_GET['agentfilter']);
    }
    //check if keywordfilter is set
    if (!empty($_POST['keywordfilter'])) {
        $keywordfilter = htmlspecialchars($_POST['keywordfilter']);
    } elseif (!empty($_GET['keywordfilter'])) {
        $keywordfilter = htmlspecialchars($_GET['keywordfilter']);
    }
    //check if datefilter1 and datefilter2 are set
    if (!empty($_POST['datefilter1']) && !empty($_POST['datefilter2'])) {
        $datefilter1 = htmlspecialchars($_POST['datefilter1']);
        $datefilter2 = htmlspecialchars($_POST['datefilter2']);
    } elseif (!empty($_GET['keywordfilter']) && !empty($_GET['datefilter2'])) {
        $datefilter1 = htmlspecialchars($_GET['datefilter1']);
        $datefilter2 = htmlspecialchars($_GET['datefilter2']);
    }
    //check if filtertype is set
    if (!empty($_POST['filtertype'])) {
        $filtertype = htmlspecialchars($_POST['filtertype']);
    } elseif (!empty($_GET['filtertype'])) {
        $filtertype = htmlspecialchars($_GET['filtertype']);
    }
    //check if filterdebug is set
    if (!empty($_POST['filterdebug'])) {
        $filterdebug = htmlspecialchars($_POST['filterdebug']);
    } elseif (!empty($_GET['filterdebug'])) {
        $filterdebug = htmlspecialchars($_GET['filterdebug']);
    }
    //check if counterize_gotopage is set
    if (!empty($_POST['counterize_gotopage'])) {
        $counterize_gotopage = htmlspecialchars($_POST['counterize_gotopage']);
    } elseif (!empty($_GET['counterize_gotopage'])) {
        $counterize_gotopage = htmlspecialchars($_GET['counterize_gotopage']);
    }
    ?>

	<div class="wrap" id="counterizehistorytop">

		<h2><?php 
    _e('Filters', COUNTERIZE_TD);
    ?>
</h2>

		<!-- Form for filters -->
		<form action="<?php 
    echo $url;
    ?>
" method="post" name="form_filter" id="form_filter">

			<fieldset>

				<legend><?php 
    _e('Define one or more filters (you can separate entries with "||")', COUNTERIZE_TD);
    ?>
</legend>

				<table summary="<?php 
    _e('Filter fields', COUNTERIZE_TD);
    ?>
">
					<tr>
						<td>
							<label for="ipfilter"><?php 
    _e('Filter for these IP addresses:', COUNTERIZE_TD);
    ?>
</label>
						</td>
						<td>
							<input type="text" size="60" placeholder="<?php 
    _e('Example: 10.20.30.%', COUNTERIZE_TD);
    ?>
" name="ipfilter" id="ipfilter"<?php 
    echo isset($ipfilter) ? ' value="' . $ipfilter . '"' : '';
    ?>
 />
						</td>
						<td>
							<input type="button" class="button-secondary" title="<?php 
    _e('Click this button to clear this field', COUNTERIZE_TD);
    ?>
" value="<?php 
    _e('Clear', COUNTERIZE_TD);
    ?>
" onclick="javascript:counterize_clear_filter_form( [ 'ipfilter' ] );" />
						</td>
					</tr>

					<tr>
						<td>
							<label for="countryfilter"><?php 
    _e('Filter for these countries:', COUNTERIZE_TD);
    ?>
</label>
						</td>
						<td>
							<input type="text" size="60" placeholder="<?php 
    _e('ISO 3166-1 Alpha-2 country codes. Example: FR for France', COUNTERIZE_TD);
    ?>
" name="countryfilter" id="countryfilter"<?php 
    echo isset($countryfilter) ? ' value="' . $countryfilter . '"' : '';
    ?>
 />
						</td>
						<td>
							<input type="button" class="button-secondary" title="<?php 
    _e('Click this button to clear this field', COUNTERIZE_TD);
    ?>
" value="<?php 
    _e('Clear', COUNTERIZE_TD);
    ?>
" onclick="javascript:counterize_clear_filter_form( [ 'countryfilter' ] );" />
						</td>
					</tr>

					<tr>
						<td>
							<label for="urifilter"><?php 
    _e('Filter for these URLs:', COUNTERIZE_TD);
    ?>
</label>
						</td>
						<td>
							<input type="text" size="60" placeholder="<?php 
    _e('Example: /2012/01/01/my-awesome-post', COUNTERIZE_TD);
    ?>
" name="urifilter" id="urifilter"<?php 
    echo isset($urifilter) ? ' value="' . $urifilter . '"' : '';
    ?>
 />
						</td>
						<td>
							<input type="button" class="button-secondary" title="<?php 
    _e('Click this button to clear this field', COUNTERIZE_TD);
    ?>
" value="<?php 
    _e('Clear', COUNTERIZE_TD);
    ?>
" onclick="javascript:counterize_clear_filter_form( [ 'urifilter' ] );" />
						</td>
					</tr>

					<tr>
						<td>
							<label for="refererfilter"><?php 
    _e('Filter for these referers:', COUNTERIZE_TD);
    ?>
</label>
						</td>
						<td>
							<input type="text" size="60" placeholder="<?php 
    _e('Example: %google.com%', COUNTERIZE_TD);
    ?>
" name="refererfilter" id="refererfilter"<?php 
    echo isset($refererfilter) ? ' value="' . $refererfilter . '"' : '';
    ?>
 />
						</td>
						<td>
							<input type="button" class="button-secondary" title="<?php 
    _e('Click this button to clear this field', COUNTERIZE_TD);
    ?>
" value="<?php 
    _e('Clear', COUNTERIZE_TD);
    ?>
" onclick="javascript:counterize_clear_filter_form( [ 'refererfilter' ] );" />
						</td>
					</tr>

					<tr>
						<td>
							<label for="agentfilter"><?php 
    _e('Filter for these user-agents:', COUNTERIZE_TD);
    ?>
</label>
						</td>
						<td>
							<input type="text" size="60" placeholder="<?php 
    _e('Example: %Firefox%', COUNTERIZE_TD);
    ?>
" name="agentfilter" id="agentfilter"<?php 
    echo isset($agentfilter) ? ' value="' . $agentfilter . '"' : '';
    ?>
 />
						</td>
						<td>
							<input type="button" class="button-secondary" title="<?php 
    _e('Click this button to clear this field', COUNTERIZE_TD);
    ?>
" value="<?php 
    _e('Clear', COUNTERIZE_TD);
    ?>
" onclick="javascript:counterize_clear_filter_form( [ 'agentfilter' ] );" />
						</td>
					</tr>

					<tr>
						<td>
							<label for="keywordfilter"><?php 
    _e('Filter for these keywords', COUNTERIZE_TD);
    ?>
</label>
						</td>
						<td>
							<input type="text" size="60" placeholder="<?php 
    _e('A list of keywords', COUNTERIZE_TD);
    ?>
" name="keywordfilter" id="keywordfilter"<?php 
    echo isset($keywordfilter) ? ' value="' . $keywordfilter . '"' : '';
    ?>
 />
						</td>
						<td>
							<input type="button" class="button-secondary" title="<?php 
    _e('Click this button to clear this field', COUNTERIZE_TD);
    ?>
" value="<?php 
    _e('Clear', COUNTERIZE_TD);
    ?>
" onclick="javascript:counterize_clear_filter_form( [ 'keywordfilter' ] );" />
						</td>
					</tr>

					<tr>
						<td>
							<label for="datefilter1"><?php 
    _e('Between', COUNTERIZE_TD);
    ?>
</label>
						</td>
						<td>
							<input type="datetime-local" name="datefilter1" id="datefilter1" placeholder="<?php 
    echo date('Y-m-d\\TH:i:s', time() - 86400);
    ?>
"<?php 
    echo isset($datefilter1) ? ' value="' . $datefilter1 . '"' : '';
    ?>
 />
							<label for="datefilter2"><?php 
    _e(' and ', COUNTERIZE_TD);
    ?>
</label>
							<input type="datetime-local" name="datefilter2" id="datefilter2" placeholder="<?php 
    echo date('Y-m-d\\TH:i:s');
    ?>
"<?php 
    echo isset($datefilter2) ? ' value="' . $datefilter2 . '"' : '';
    ?>
 />
						</td>
						<td>
							<input type="button" class="button-secondary" title="<?php 
    _e('Click this button to clear these fields', COUNTERIZE_TD);
    ?>
" value="<?php 
    _e('Clear', COUNTERIZE_TD);
    ?>
" onclick="javascript:counterize_clear_filter_form( [ 'datefilter1', 'datefilter2' ] );" />
						</td>
					</tr>

					<tr>
						<td>
							<label for="filterinclude"><?php 
    _e('Include filter', COUNTERIZE_TD);
    ?>
</label>
						</td>
						<td colspan="2">
							<input type="radio" name="filtertype" id="filterinclude" value="in"<?php 
    echo !isset($filtertype) || isset($filtertype) && $filtertype == 'in' ? ' checked="checked"' : '';
    ?>
 />
							<span><?php 
    _e('(Matches everything included in the filters)', COUNTERIZE_TD);
    ?>
</span>
						</td>
					</tr>

					<tr>
						<td>
							<label for="filterexclude"><?php 
    _e('Exclude filter', COUNTERIZE_TD);
    ?>
</label>
						</td>
						<td colspan="2">
							<input type="radio" name="filtertype" id="filterexclude" value="ex"<?php 
    echo isset($filtertype) && $filtertype == 'ex' ? ' checked="checked"' : '';
    ?>
 />
							<span><?php 
    _e('(Matches everything not included in the filters)', COUNTERIZE_TD);
    ?>
</span>
						</td>
					</tr>

					<tr>
						<td>
							<label for="filterlike"><?php 
    _e('LIKE filter', COUNTERIZE_TD);
    ?>
</label>
						</td>
						<td colspan="2">
							<input type="radio" name="filtertype" id="filterlike" title="<?php 
    _e("Escape wildcards characters with '\\' if they should not to be processed as wildcards characters.", COUNTERIZE_TD);
    ?>
" value="like"<?php 
    echo isset($filtertype) && $filtertype == 'like' ? ' checked="checked"' : '';
    ?>
 />
							<span><?php 
    _e("(Wildcard characters '%' and '_' are allowed)", COUNTERIZE_TD);
    ?>
</span>
						</td>
					</tr>

					<tr>
						<td>
							<label for="filternotlike"><?php 
    _e('NOT LIKE filter', COUNTERIZE_TD);
    ?>
</label>
						</td>
						<td colspan="2">
							<input type="radio" name="filtertype" id="filternotlike" title="<?php 
    _e("Escape wildcards characters with '\\' if they should not to be processed as wildcards characters.", COUNTERIZE_TD);
    ?>
" value="notlike"<?php 
    echo isset($filtertype) && $filtertype == 'notlike' ? ' checked="checked"' : '';
    ?>
 />
							<span><?php 
    _e("(Wildcard characters '%' and '_' are allowed)", COUNTERIZE_TD);
    ?>
</span>
						</td>
					</tr>

					<tr>
						<td>
							<label for="filterdebug"><?php 
    _e('Debug query', COUNTERIZE_TD);
    ?>
</label>
						</td>
						<td colspan="2">
							<input type="checkbox" name="filterdebug" id="filterdebug" value="filterdebug"<?php 
    echo isset($filterdebug) && $filterdebug == 'filterdebug' ? ' checked="checked"' : '';
    ?>
 />
							<span><?php 
    _e('(Check this to see the generated SQL query)', COUNTERIZE_TD);
    ?>
</span>
						</td>
					</tr>

					<tr>
						<td colspan="3"><?php 
    _e('Click on the <a href="#contextual-help-wrap">Help link</a> above to learn more about what you can do with filters.', COUNTERIZE_TD);
    ?>
</td>
					</tr>

				</table>

				<input type="hidden" name="counterize_hidden_check" id="counterize_hidden_check" value="present" />

				<?php 
    wp_nonce_field('counterize_filter_data', 'counterize_filter_data_field');
    ?>

				<input type="submit" class="button-primary" title="<?php 
    _e('Click this button to submit your filters', COUNTERIZE_TD);
    ?>
" name="counterize_filter_submit" id="counterize_filter_submit" value="<?php 
    _e('Submit filter', COUNTERIZE_TD);
    ?>
" />
				<input type="button" class="button-primary" title="<?php 
    _e('Click this button to clear ALL the filters', COUNTERIZE_TD);
    ?>
" value="<?php 
    _e('Clear form', COUNTERIZE_TD);
    ?>
" onclick="javascript:counterize_clear_filter_form( [ 'ipfilter', 'urifilter', 'refererfilter', 'agentfilter', 'countryfilter' ] );" />
				<input type="reset" class="button-primary" title="<?php 
    _e('Click this button to cancel any change made to filters', COUNTERIZE_TD);
    ?>
" value="<?php 
    _e('Cancel changes', COUNTERIZE_TD);
    ?>
" />
				<a href="admin.php?page=<?php 
    echo $frompage;
    ?>
" title="<?php 
    _e('Click this button to reset the whole form (will refresh the page)', COUNTERIZE_TD);
    ?>
" class="button-secondary"><?php 
    _e('Reset filters', COUNTERIZE_TD);
    ?>
</a>

			</fieldset>

		</form>
		<br />

		<h2><?php 
    echo $howmany;
    ?>
</h2>

		<?php 
    $entries_tmp = counterize_getentries_sql($amount);
    if (isset($filterdebug) && $filterdebug == 'filterdebug') {
        echo '<div id="filterdebug"><h3>Debug</h3><p><pre>' . wordwrap(htmlspecialchars($entries_tmp[0]), 80, "\n") . '</pre></p></div>';
    }
    $entries = $wpdb->get_results($entries_tmp[0]);
    $nbentries = $entries_tmp[1];
    $lastpage = $entries_tmp[2];
    //compute the current page number
    if (isset($counterize_gotopage) && is_numeric($counterize_gotopage)) {
        $currentpage = intval($counterize_gotopage);
    } else {
        $currentpage = 1;
    }
    if ($currentpage < 1) {
        $currentpage = 1;
    } elseif ($currentpage > $lastpage) {
        $currentpage = $lastpage;
    }
    //generate the navigation links
    $nav_link = wp_nonce_url($url, 'action_nav_link');
    $nav_link .= isset($ipfilter) ? '&amp;ipfilter=' . htmlspecialchars($ipfilter) : '';
    $nav_link .= isset($countryfilter) ? '&amp;countryfilter=' . htmlspecialchars($countryfilter) : '';
    $nav_link .= isset($urifilter) ? '&amp;urifilter=' . htmlspecialchars($urifilter) : '';
    $nav_link .= isset($refererfilter) ? '&amp;refererfilter=' . htmlspecialchars($refererfilter) : '';
    $nav_link .= isset($agentfilter) ? '&amp;agentfilter=' . htmlspecialchars($agentfilter) : '';
    $nav_link .= isset($keywordfilter) ? '&amp;keywordfilter=' . htmlspecialchars($keywordfilter) : '';
    $nav_link .= isset($filtertype) ? '&amp;filtertype=' . htmlspecialchars($filtertype) : '';
    $nav_frst_link = $nav_link . '&amp;counterize_gotopage=1';
    $nav_prev_link = $nav_link . '&amp;counterize_gotopage=' . ($currentpage - 1);
    $nav_next_link = $nav_link . '&amp;counterize_gotopage=' . ($currentpage + 1);
    $nav_last_link = $nav_link . '&amp;counterize_gotopage=' . $lastpage;
    if (!empty($_POST) && isset($_POST['counterize_gotopage'])) {
        if (!check_admin_referer('counterize_history_nav', 'counterize_history_nav_field')) {
            echo "<p>" . __('Nonce not verified. What are you trying to do?', COUNTERIZE_TD) . "</p>";
            exit;
        }
    }
    ?>

		<!-- Navigation bar -->
		<div id="counterize_history_navigationbar">
			<ul>
				<?php 
    if ($currentpage > 1) {
        ?>
				<li><a href="<?php 
        echo $nav_frst_link;
        ?>
" class="button-secondary"><?php 
        _e('&laquo;&nbsp;First page', COUNTERIZE_TD);
        ?>
</a></li>
				<li><a href="<?php 
        echo $nav_prev_link;
        ?>
" class="button-secondary"><?php 
        _e('&lsaquo;&nbsp;Previous page', COUNTERIZE_TD);
        ?>
</a></li>
				<?php 
    }
    ?>
				<li>
					<form action="<?php 
    echo $url;
    ?>
" method="post" name="counterize_form_nav" id="counterize_form_nav">
						<label for="counterize_gotopage"><?php 
    _e('Go to page:', COUNTERIZE_TD);
    ?>
</label>
						<input type="text" id="counterize_gotopage" name="counterize_gotopage" size="2" value="<?php 
    echo $currentpage;
    ?>
" />
						<span>&nbsp;/&nbsp;<?php 
    echo $lastpage;
    ?>
</span>
						<?php 
    wp_nonce_field('counterize_history_nav', 'counterize_history_nav_field');
    ?>
						<input type="submit" value="<?php 
    _e('OK', COUNTERIZE_TD);
    ?>
" class="button-secondary" />
					</form>
				</li>
				<?php 
    if ($currentpage < $lastpage) {
        ?>
				<li><a href="<?php 
        echo $nav_next_link;
        ?>
" class="button-secondary"><?php 
        _e('Next page&nbsp;&rsaquo;', COUNTERIZE_TD);
        ?>
</a></li>
				<li><a href="<?php 
        echo $nav_last_link;
        ?>
" class="button-secondary"><?php 
        _e('Last page&nbsp;&raquo;', COUNTERIZE_TD);
        ?>
</a></li>
				<?php 
    }
    ?>
			</ul>
		</div>

		<?php 
    $killmass_url = "{$url}&amp;killmass=yes";
    $killmass_link = wp_nonce_url($killmass_url, "action_killmass");
    ?>

		<!-- History data begins here -->
		<form method="post" action="<?php 
    echo $killmass_link;
    ?>
" name="tablesForm" id="tablesForm">

			<table id="counterizehistorytable" width="100%" cellpadding="3" cellspacing="3" rules="rows" summary="<?php 
    _e('History', COUNTERIZE_TD);
    ?>
">
				<thead>
					<tr class="alternate">
						<th style="width: 3%"><?php 
    _e('Select', COUNTERIZE_TD);
    ?>
</th>
						<th style="width: 3%"><?php 
    _e('ID', COUNTERIZE_TD);
    ?>
</th>
						<th style="width: 10%"><?php 
    _e('IP', COUNTERIZE_TD);
    ?>
</th>
						<th style="width: 10%"><?php 
    _e('Country', COUNTERIZE_TD);
    ?>
</th>
						<th style="width: 10%"><?php 
    _e('Timestamps', COUNTERIZE_TD);
    ?>
</th>
						<th style="width: 20%"><?php 
    _e('URL', COUNTERIZE_TD);
    ?>
</th>
						<th style="width: 20%"><?php 
    _e('Referers', COUNTERIZE_TD);
    ?>
</th>
						<th style="width: 12%"><?php 
    _e('User-agents', COUNTERIZE_TD);
    ?>
</th>
						<th style="width: 10%"><?php 
    _e('Keywords', COUNTERIZE_TD);
    ?>
</th>
						<th style="width: 2%"><?php 
    _e('Kill', COUNTERIZE_TD);
    ?>
</th>
					</tr>
				</thead>
				<tfoot>
					<tr class="alternate">
						<th><?php 
    _e('Select', COUNTERIZE_TD);
    ?>
</th>
						<th><?php 
    _e('ID', COUNTERIZE_TD);
    ?>
</th>
						<th><?php 
    _e('IP', COUNTERIZE_TD);
    ?>
</th>
						<th><?php 
    _e('Country', COUNTERIZE_TD);
    ?>
</th>
						<th><?php 
    _e('Timestamps', COUNTERIZE_TD);
    ?>
</th>
						<th><?php 
    _e('URL', COUNTERIZE_TD);
    ?>
</th>
						<th><?php 
    _e('Referers', COUNTERIZE_TD);
    ?>
</th>
						<th><?php 
    _e('User-agents', COUNTERIZE_TD);
    ?>
</th>
						<th><?php 
    _e('Keywords', COUNTERIZE_TD);
    ?>
</th>
						<th><?php 
    _e('Kill', COUNTERIZE_TD);
    ?>
</th>
					</tr>
				</tfoot>
				<tbody>

				<?php 
    //$url = "admin.php?page={$frompage}";
    $uri_filter_link = wp_nonce_url($url, 'action_uri_filter');
    $ip_filter_link = wp_nonce_url($url, 'action_ip_filter');
    $country_filter_link = wp_nonce_url($url, 'action_country_filter');
    $referer_filter_link = wp_nonce_url($url, 'action_referer_filter');
    $agent_filter_link = wp_nonce_url($url, 'action_agent_filter');
    $keyword_filter_link = wp_nonce_url($url, 'action_agent_keyword');
    $uri_kill_link = wp_nonce_url($url, 'action_uri_kill');
    if (!empty($_POST) && isset($_POST['counterize_hidden_check'])) {
        if (!check_admin_referer('counterize_filter_data', 'counterize_filter_data_field')) {
            echo '<p>' . __('Nonce not verified. What are you trying to do?', COUNTERIZE_TD) . '</p>';
            exit;
        }
    }
    $i = 0;
    $offset = 0;
    $entrycounter = 1;
    foreach ($entries as $entry) {
        if ($i % 25 == 0 && $i > 0) {
            $offset++;
            ?>

				</tbody>
				<tbody>
					<tr class="alternate repeat">
						<th><?php 
            _e('Select', COUNTERIZE_TD);
            ?>
</th>
						<th><?php 
            _e('ID', COUNTERIZE_TD);
            ?>
</th>
						<th><?php 
            _e('IP', COUNTERIZE_TD);
            ?>
</th>
						<th><?php 
            _e('Country', COUNTERIZE_TD);
            ?>
</th>
						<th><?php 
            _e('Timestamps', COUNTERIZE_TD);
            ?>
</th>
						<th><?php 
            _e('URL', COUNTERIZE_TD);
            ?>
</th>
						<th><?php 
            _e('Referers', COUNTERIZE_TD);
            ?>
</th>
						<th><?php 
            _e('User-agents', COUNTERIZE_TD);
            ?>
</th>
						<th><?php 
            _e('Keywords', COUNTERIZE_TD);
            ?>
</th>
						<th><?php 
            _e('Kill', COUNTERIZE_TD);
            ?>
</th>
					</tr>

				<?php 
        }
        ?>

					<tr <?php 
        if (($i + $offset) % 2) {
            echo 'class="alternate"';
        }
        ?>
>
						<td style="text-align: center">
							<?php 
        echo $entrycounter;
        $entrycounter++;
        ?>
							<small>
								<input type="checkbox"
								name='counterize_killemall[<?php 
        echo $entry->id;
        ?>
]'
								value="<?php 
        echo $entry->id;
        ?>
" />
							</small>
						</td>

						<td style="text-align: center">
							<small>
								<?php 
        echo $entry->id;
        ?>
							</small>
						</td>


						<td style="text-align: center">
							<small>
								<?php 
        printf("<a href='%s&amp;ipfilter=%s' onclick='javascript:add_filter( \"%s\", \"ipfilter\" ); return false;' title='%s' class='button-secondary'>F</a>\n\t\t\t\t\t\t\t\t", $ip_filter_link, $entry->IP, $entry->IP, __('Add a filter for this IP address', COUNTERIZE_TD));
        printf('<a target="_blank" href="%s%s" title="%s" class="button-secondary">G</a>
								', counterize_get_option('geoip'), $entry->IP, __('Geo IP tool service', COUNTERIZE_TD));
        printf(' <a target="_blank" href="%s%s" title="%s">&#x202A;%s&#x202C;</a>
								', counterize_get_option('whois'), $entry->IP, __('Whois service for this IP address', COUNTERIZE_TD), $entry->IP);
        ?>

							</small>
						</td>

						<td style="text-align: center">
							<small>
								<a href="<?php 
        echo $country_filter_link . "&amp;countryfilter=" . htmlspecialchars($entry->countrycode);
        ?>
" onclick="javascript:counterize_add_filter( '<?php 
        echo htmlspecialchars($entry->countrycode);
        ?>
', 'countryfilter' ); return false;" title="<?php 
        _e('Add a filter for this country', COUNTERIZE_TD);
        ?>
" class="button-secondary">F</a>
								 <span><?php 
        echo counterize_get_countrycode3($entry->countrycode);
        ?>
</span>
								<?php 
        if (file_exists(COUNTERIZE_PLUGIN_DIR . "/ip_files/flags/{$entry->countrycode}.gif")) {
            echo "&nbsp;<img src='" . COUNTERIZE_PLUGIN_URL . "/ip_files/flags/{$entry->countrycode}.gif' title='" . counterize_get_countryname($entry->countrycode) . " ({$entry->countrycode})' alt='" . sprintf(__('National flag of %s', COUNTERIZE_TD), counterize_get_countryname($entry->countrycode)) . "' />";
        } elseif (file_exists(COUNTERIZE_PLUGIN_DIR . "/ip_files/flags/" . strtolower($entry->countrycode) . ".gif")) {
            //sometimes some tools such as unzip modify the filenames to be lowercase (happened to me)
            echo "&nbsp;<img src='" . COUNTERIZE_PLUGIN_URL . "/ip_files/flags/" . strtolower($entry->countrycode) . ".gif' title='" . counterize_get_countryname($entry->countrycode) . " ({$entry->countrycode})' alt='" . sprintf(__('National flag of %s', COUNTERIZE_TD), counterize_get_countryname($entry->countrycode)) . "' />";
        }
        ?>
							</small>
						</td>

						<td style="text-align: center">
							<small><?php 
        echo $entry->timestamp;
        ?>
 </small>
						</td>

						<td>
							<small>
								<a href="<?php 
        echo $uri_filter_link . "&amp;urifilter=" . htmlspecialchars($entry->url);
        ?>
" onclick="javascript:counterize_add_filter( '<?php 
        echo htmlspecialchars($entry->url);
        ?>
', 'urifilter' ); return false;" title="<?php 
        _e('Add a filter for this URL', COUNTERIZE_TD);
        ?>
" class="button-secondary">F</a>
								 <?php 
        echo '<a href="' . htmlspecialchars($entry->url) . '" target="_blank">&#x202A;' . htmlspecialchars(counterize_wordwrap($entry->url));
        ?>
&#x202C;</a>
							</small>
						</td>

						<td>
							<small>
							<?php 
        if ($entry->referer != "unknown") {
            ?>
<a href="<?php 
            echo $referer_filter_link . "&amp;refererfilter=" . htmlspecialchars($entry->referer);
            ?>
" onclick="javascript:counterize_add_filter( '<?php 
            echo htmlspecialchars($entry->referer);
            ?>
', 'refererfilter' ); return false;" title="<?php 
            _e('Add a filter for this referer', COUNTERIZE_TD);
            ?>
" class="button-secondary">F</a>
								<?php 
            echo ' <a href="' . htmlspecialchars($entry->referer) . '" target="_blank">&#x202A;' . htmlspecialchars(counterize_wordwrap($entry->referer)) . '&#x202C;</a>';
            ?>
								<?php 
        } else {
            ?>
<a href="<?php 
            echo $referer_filter_link . "&amp;refererfilter=" . htmlspecialchars($entry->referer);
            ?>
" onclick="javascript:counterize_add_filter( '<?php 
            echo htmlspecialchars($entry->referer);
            ?>
', 'refererfilter' ); return false;" title="<?php 
            _e('Add a filter for this referer', COUNTERIZE_TD);
            ?>
" class="button-secondary">F</a>
								 <?php 
            echo htmlspecialchars(counterize_wordwrap($entry->referer));
        }
        ?>
							</small>
						</td>

						<td>
							<small>
								<span title="<?php 
        echo htmlspecialchars($entry->useragent);
        ?>
"><?php 
        echo counterize_browser_string($entry->useragent, true, '<br />');
        ?>
</span>
								 <a href="<?php 
        echo $agent_filter_link . '&amp;agentfilter=' . htmlspecialchars(urlencode($entry->useragent));
        ?>
" onclick="javascript:counterize_add_filter( '<?php 
        echo htmlspecialchars($entry->useragent);
        ?>
', 'agentfilter' ); return false;" title="<?php 
        _e('Add a filter for this user-agent', COUNTERIZE_TD);
        ?>
" class="button-secondary">F</a>
							</small>
						</td>

						<td style="text-align: left">
							<small>
								<?php 
        if (!empty($entry->keyword)) {
            ?>
								<a href="<?php 
            echo $keyword_filter_link . '&amp;keywordfilter=' . htmlspecialchars($entry->keyword);
            ?>
" onclick="javascript:counterize_add_filter( '<?php 
            echo htmlspecialchars($entry->keyword);
            ?>
', 'keywordfilter' ); return false;" title="<?php 
            _e('Add a filter for this keyword', COUNTERIZE_TD);
            ?>
" class="button-secondary">F</a>
								<?php 
        }
        ?>
								<?php 
        echo empty($entry->keyword) ? "&nbsp;" : counterize_wordwrap(htmlspecialchars($entry->keyword));
        ?>
							</small>
						</td>

						<td style="text-align: center">
							<a href="javascript:counterize_conf( '<?php 
        echo $uri_kill_link . "&amp;kill={$entry->id}";
        ?>
' );" class="button-secondary counterize_history_killbutton" title="<?php 
        _e('Click here to delete this entry', COUNTERIZE_TD);
        ?>
">X</a>
						</td>
					</tr>
			<?php 
        $i++;
    }
    unset($entries);
    ?>
				</tbody>
			</table>

			<input
				type="button"
				class="button-primary"
				name="counterize_checkAll"
				value="<?php 
    _e('Check all', COUNTERIZE_TD);
    ?>
"
				onclick="javascript:counterize_check_all( document.tablesForm );" />
			<input
				type="button"
				class="button-primary"
				name="counterize_uncheckAll"
				value="<?php 
    _e('Uncheck all', COUNTERIZE_TD);
    ?>
"
				onclick="javascript:counterize_uncheck_all( document.tablesForm );" />
			<input
				type="submit"
				class="button-primary"
				value="<?php 
    _e('Delete checked entries', COUNTERIZE_TD);
    ?>
" />
		</form>

		<div id="counterize_history_navigationbar2">
			<ul>
				<?php 
    if ($currentpage > 1) {
        ?>
				<li><a href="<?php 
        echo $nav_frst_link;
        ?>
" class="button-secondary"><?php 
        _e('&laquo;&nbsp;First page', COUNTERIZE_TD);
        ?>
</a></li>
				<li><a href="<?php 
        echo $nav_prev_link;
        ?>
" class="button-secondary"><?php 
        _e('&lsaquo;&nbsp;Previous page', COUNTERIZE_TD);
        ?>
</a></li>
				<?php 
    }
    ?>
				<li><a href="#counterizehistorytop" class="button-secondary"><?php 
    _e('&uarr;&nbsp;Top of the page&nbsp;&uarr;', COUNTERIZE_TD);
    ?>
</a></li>
				<?php 
    if ($currentpage < $lastpage) {
        ?>
				<li><a href="<?php 
        echo $nav_next_link;
        ?>
" class="button-secondary"><?php 
        _e('Next page&nbsp;&rsaquo;', COUNTERIZE_TD);
        ?>
</a></li>
				<li><a href="<?php 
        echo $nav_last_link;
        ?>
" class="button-secondary"><?php 
        _e('Last page&nbsp;&raquo;', COUNTERIZE_TD);
        ?>
</a></li>
				<?php 
    }
    ?>
			</ul>
		</div>

	</div>

<?php 
}
function counterize_killEntry($entryID)
{
    global $wpdb;
    $entries_tmp = counterize_getentries_sql(1, $entryID);
    $entries = $wpdb->get_results($entries_tmp[0]);
    foreach ($entries as $entry) {
        $sql = "DELETE FROM `" . counterize_logTable() . "` WHERE `id`={$entry->id}";
        $num = $wpdb->query($sql);
        unset($sql);
        $sql = "UPDATE IGNORE `" . counterize_pageTable() . "` SET `count` = `count` - 1 WHERE `pageID`={$entry->pageID}";
        $num = $wpdb->query($sql);
        unset($sql);
        $sql = "UPDATE IGNORE `" . counterize_refererTable() . "` SET `count` = `count` - 1 WHERE `refererID`={$entry->refererID}";
        $num = $wpdb->query($sql);
        unset($sql);
        $sql = "UPDATE IGNORE `" . counterize_agentsTable() . "` SET `count` = `count` - 1 WHERE `agentID`={$entry->agentID}";
        $num = $wpdb->query($sql);
        unset($sql);
        $sql = "UPDATE IGNORE `" . counterize_keywordTable() . "` SET `count` = `count` - 1 WHERE `keywordID`={$entry->keywordID}";
        $num = $wpdb->query($sql);
        unset($sql);
        $sql = "UPDATE IGNORE `" . counterize_countryTable() . "` SET `count` = `count` - 1 WHERE `countryID`={$entry->countryID}";
        $num = $wpdb->query($sql);
        unset($sql);
    }
    unset($entries_tmp, $entries);
}