Пример #1
0
function render_page_html()
{
    scripts_i18n();
    page_head();
    display_filters();
    display_content();
    page_foot();
}
Пример #2
0
function render_page()
{
    global $ss;
    $origin = isset($_GET['origin']) && $_GET['origin'] != 'overview' ? $_GET['origin'] : '';
    $failed_login = false;
    // process login request
    if (isset($_POST['simple-stats-login'])) {
        if ($_POST['username'] == $ss->options['username'] && $ss->hash(trim($_POST['password'])) == $ss->options['password']) {
            @setcookie('simple_stats', $ss->hash($ss->options['username'] . $ss->options['password']), time() + 31536000, '/', '');
            header('Location: ./' . ($origin ? './?p=' . $origin : ''), true, 302);
            exit;
        } else {
            $failed_login = true;
        }
    }
    page_head();
    ?>
<div id="main">
<?php 
    if ($origin == 'logout') {
        echo '<p>You have logged out of Simple Stats. You can <a href="./?p=login">login again</a> if you like.';
    } else {
        ?>
<h2><?php 
        echo __('Login');
        ?>
</h2>
<?php 
        if ($failed_login) {
            echo '<p class="center">' . __('Sorry, the username and password combination that you entered was incorrect.');
        }
        ?>
<form action="./?p=login&amp;origin=<?php 
        echo $origin;
        ?>
" method="post">
<table>
<tr><th><label for="username"><?php 
        echo __('User name');
        ?>
</label><td><input type="text" name="username" value="" tabindex="1">
<tr><th><label for="password"><?php 
        echo __('Password');
        ?>
</label><td><input type="password" name="password" value="" tabindex="2">
</table>
<p class="center"><input type="submit" name="simple-stats-login" value="<?php 
        echo __('Submit');
        ?>
" tabindex="3">
</form>
<?php 
    }
    ?>
</div>
<?php 
    page_foot();
}
Пример #3
0
        if (!empty($archive_table_missing)) {
            echo '<p>To alter the archive table:</p><pre>';
            foreach ($archive_alter_queries as $archive_alter_query) {
                echo htmlspecialchars($archive_alter_query) . ";\n";
            }
            echo '</pre>';
        }
    }
}
///////////////////////////////////////////////////////////// 'Next step' button
if ($next_action) {
    echo '<form method="post" action="?p=setup">';
    echo '<p>';
    if ($next_action) {
        echo "<input type='hidden' name='action' value='{$next_action}'>";
    }
    echo '<input type="submit" value="Next step" /></p>';
    echo '</form>';
} else {
    echo '<form action="./?p=options" method="post">';
    echo '<input type="hidden" name="action" value="complete_setup">';
    echo '<p><input type="submit" value="Finish" /></p>' . "\n";
    echo '</form>' . "\n";
}
?>
</div>

</div>
<?php 
page_foot();
Пример #4
0
function render_page()
{
    global $ss;
    $options = $ss->options;
    if (isset($_POST['update_options'])) {
        foreach (array('stats_enabled', 'log_user_agents', 'log_bots') as $bool) {
            $options[$bool] = isset($_POST[$bool]);
        }
        foreach (array('site_name', 'username', 'tz', 'lang') as $text) {
            $options[$text] = $_POST[$text];
        }
        $pw = trim($_POST['password']);
        if ($pw) {
            // password has been set/changed
            $options['password'] = $ss->hash($pw);
        }
        $options['aggregate_after'] = intval($_POST['aggregate_after']);
        // set login option
        $options['login_required'] = false;
        if (isset($_POST['login_required'])) {
            $options['login_required'] = 'all';
        } elseif (isset($_POST['login_required_config'])) {
            $options['login_required'] = 'config';
        }
        $ips = explode("\n", str_replace("\r\n", "\n", $_POST['ignored_ips']));
        $options['ignored_ips'] = array();
        // we don't check the validity of IPs
        foreach ($ips as $ip) {
            $ip = trim($ip);
            if ($ip) {
                $options['ignored_ips'][] = $ip;
            }
        }
        foreach ($options as $option => $value) {
            $ss->update_option($option, $value);
        }
    }
    page_head();
    echo '<div id="main">';
    echo '<h2>' . __('Configuration') . '</h2>';
    echo '<p> ' . __('In order for Simple Stats to record hits on your site, you need to include the <code>stats-include.php</code> in your site\' code. Insert the following code where it will be run on every page load:');
    echo ' <code>' . htmlspecialchars('<?php @include_once( \'' . str_replace('\\', '/', SIMPLE_STATS_PATH) . '/stats-include.php\' ); ?>') . '</code>';
    echo '<form action="?p=options" method="post" id="options-form">';
    if (defined('SIMPLE_STATS_PASSWORD_RESET') && SIMPLE_STATS_PASSWORD_RESET) {
        echo '<p style="color:red">' . __('Your Simple Stats username and password have been reset because you defined the constant <code>SIMPLE_STATS_PASSWORD_RESET</code> in your <code>config.php</code> file. Please remove that definition in order to set new login credentials.');
    }
    $fields = array('stats_enabled' => array(__('Enable Simple Stats'), '<input type="checkbox" id="stats_enabled" name="stats_enabled" value="1" ' . checked($options['stats_enabled']) . '>'), 'site_name' => array(__('Site name'), '<input type="text" id="site_name" name="site_name" value="' . htmlspecialchars($options['site_name']) . '">'), 'login_required_config' => array(__('Require login to edit configuration') . '<br><small>' . __('Visits from users logged in to Simple Stats will not be recorded.') . '</small>', '<input type="checkbox" id="login_required_config" name="login_required_config" value="1" ' . checked($options['login_required']) . '>'), 'login_required' => array(__('Require login to view statistics'), '<input type="checkbox" id="login_required" name="login_required" value="1" ' . checked($options['login_required'], 'all') . '>'), 'username' => array(__('Username for Simple Stats login'), '<input type="text" id="username" name="username" value="' . htmlspecialchars($options['username']) . '">'), 'password' => array(__('Password for Simple Stats login') . ($options['password'] ? ' <small class="hide-if-js">' . __('(saved, click to change)') . '</small>' : ''), '<input type="password" id="password" name="password" value="">' . ($options['password'] ? '<input type="hidden" id="saved_password_exists" value="1">' : '')), 'tz' => array(__('Time zone'), '<select id="tz" name="tz">' . tz_options($options['tz']) . '</select>'), 'lang' => array(__('Language') . '<br><small>' . __('Please enter your language identifier in the form "en-gb".') . '</small>', '<input type="text" id="lang" name="lang" maxlength="5" size="5" value="' . $options['lang'] . '">'), 'log_user_agents' => array(__('Log full user agent string') . '<br><small>' . __('Operating system, browser and version will always be recorded. Selecting this option will considerably increase the size of the Simple Stats database.') . '</small>', '<input type="checkbox" id="log_user_agents" name="log_user_agents" value="1" ' . checked($options['log_user_agents']) . '>'), 'log_bots' => array(__('Log visits from robots'), '<input type="checkbox" id="log_bots" name="log_bots" value="1" ' . checked($options['log_bots']) . '>'), 'ignored_ips' => array(__('Ignore these IP addresses:' . '<br><small>' . __('Please enter one IP address per line.') . '</small>'), '<textarea id="ignored_ips" name="ignored_ips">' . implode("\n", $options['ignored_ips']) . '</textarea>'), 'aggregate_after' => array(__('Aggregate data after:') . '<br><small>' . __('Aggregrating data will significantly reduce the size of the database, but will mean that you can only view summarised data for each month.') . '</small>', '<select type="checkbox" id="aggregate_after" name="aggregate_after">' . '<option value="0"' . selected($options['aggregate_after'], 0) . '>' . __('never aggregate data') . '</option>' . '<option value="3"' . selected($options['aggregate_after'], 3) . '>3 ' . __('months') . '</option>' . '<option value="6"' . selected($options['aggregate_after'], 6) . '>6 ' . __('months') . '</option>' . '<option value="9"' . selected($options['aggregate_after'], 9) . '>9 ' . __('months') . '</option>' . '<option value="12"' . selected($options['aggregate_after'], 12) . '>12 ' . __('months') . '</option>' . '</select>'));
    echo '<table class="wide"><tbody>';
    foreach ($fields as $option => $v) {
        $name = $v[0];
        $input = $v[1];
        echo "<tr><th class='left'><label for='{$option}'>{$name}</label><td class='center'>{$input}";
    }
    echo '</table>';
    echo '<p class="center"><input type="submit" name="update_options" value="' . __('Update options') . '">';
    echo '</form></div>';
    //main
    ?>
	<script>
	$(document).ready( function(){
		$(".hide-if-js").hide();

		var needs_password = false;
		$("#login_required, #login_required_config").change( function(){
			var uprow = $("#username, #password").closest("tr");
			if( $("#login_required").is(":checked") || $("#login_required_config").is(":checked") ) {
				uprow.fadeIn();
				needs_password = true;
			}
			else {
				uprow.fadeOut();
				needs_password = false;
			}
		});
		$("#login_required, #login_required_config").change();

		var pw = $("#password"), is_saved = $("#saved_password_exists").val();
		if( is_saved ) {
			var ph = $( '<a><?php 
    echo htmlspecialchars(__('(saved, click to change)'));
    ?>
</a>' );
			pw.hide().after( ph );
			ph.click( function(){
				ph.hide();
				pw.show().focus();
			});
			pw.blur( function() {
				if( !pw.val() ) {
					pw.hide();
					ph.show();
				}
			});
		};
		
		$("#options-form").submit( function(e){
			if( needs_password && ( ! $("#username").val() || ( ! pw.val() && ! is_saved ) ) ) {
				e.preventDefault();
				alert( "<?php 
    echo htmlspecialchars(__('You have not supplied a username and/or password. Please enter a username and password to enable restricted access.'));
    ?>
" );
			}
		});
	});
	</script>
	<?php 
    page_foot();
}
Пример #5
0
function display_form(&$http_vars, $cond_array = array())
{
    global $PHP_SELF;
    if (!defined("LAY_SEARCH_INC")) {
        include "layout/lay_search.inc";
    }
    if (!defined("LAY_DIRECTORY_INC")) {
        include "layout/lay_directory.inc";
    }
    $kat = ereg_replace('^/([^-\\]*-[^/]*)(.*)', '\\2', $PHP_SELF);
    page_head($http_vars, $kat);
    $tpl = new Template(APPLICATION_HOME . "/templates/search", "keep");
    $tpl->set_file(array("main" => "main.html"));
    $tpl->set_var("IWANTTO", print_iwantto('/', $caps));
    $tpl->set_var("EXPERTS", "");
    $tpl->set_var("TRAILS", "");
    $tpl->set_var("CATEGORIES", print_adv_search_form($http_vars, $cond_array, parent_path($kat)));
    $tpl->parse("main", "main");
    $tpl->p("main");
    page_foot();
}
Пример #6
0
function render_page()
{
    global $ss;
    scripts_i18n();
    page_head();
    echo '<div id="main">';
    echo '<h2>' . __('Latest visitors') . '</h2>';
    $page_size = 20;
    $offset = isset($_GET['offset']) ? abs(intval($_GET['offset'])) : 0;
    $query = "SELECT * FROM `{$ss->tables['visits']}` ORDER BY `date` DESC, `start_time` DESC LIMIT {$offset},{$page_size}";
    $visits = array();
    if ($result = $ss->query($query)) {
        while ($assoc = @mysql_fetch_assoc($result)) {
            $visits[] = $assoc;
        }
    }
    $ua = new SimpleStatsUA();
    echo '<table id="paths" class="center wide" data-offset="' . $offset . '" data-page_size="' . $page_size . '"><thead>';
    echo '<tr><th colspan="2" class="left">' . __('IP Address') . '/' . __('Pages');
    echo '<th>' . __('Time');
    echo '<th>' . __('Browser');
    echo '<th>' . __('Operating system');
    echo '<th>' . __('Country');
    echo '<tbody>';
    foreach ($visits as $visit) {
        $start_ts = strtotime($visit['date'] . ' ' . $visit['start_time']);
        $hits = explode("\n", $visit['resource']);
        $dy_label = strftime('%d %b', $start_ts);
        $start_ts = date('H:i', $start_ts);
        $full_ua = $ss->options['log_user_agents'] && !empty($visit['user_agent']) ? $visit['user_agent'] : '';
        if ($visit['browser'] == 0) {
            $browser_name = '';
        } elseif ($visit['browser'] == 1) {
            $browser_name = __('(Robot)');
        } else {
            $browser_name = $ua->browser_name_from_id($visit['browser']);
        }
        $robot_class = $visit['browser'] == 1 ? ' bot' : '';
        $title = $full_ua ? ' title="' . htmlspecialchars($full_ua) . '"' : '';
        echo "<tr class='visit-header{$robot_class}'>";
        echo '<td colspan="2" class="left">' . htmlspecialchars($visit['remote_ip']);
        echo '<td>' . $dy_label . '</td>';
        echo "<td class='ua'{$title}>" . htmlspecialchars($browser_name) . ' ' . htmlspecialchars($visit['version']);
        echo '<td>' . htmlspecialchars($ua->platform_name_from_id($visit['platform']));
        echo '<td>' . htmlspecialchars(country_name($visit['country'])) . '</tr>';
        $row = 0;
        foreach ($hits as $hit) {
            if (empty($hit)) {
                continue;
            }
            @(list($time, $resource) = explode(' ', $hit, 2));
            // dump the seconds part of the time
            $time = substr($time, 0, 5);
            $r = htmlspecialchars($resource);
            echo '<tr class="hit">';
            echo '<td colspan="2" class="left"><a href="' . $r . '" class="goto">&rarr;</a> ' . filter_link(array('resource' => $resource), $resource) . "<td>{$time}";
            if ($row == 0 && !empty($visit['referrer'])) {
                echo '<td colspan="3" class="right">';
                if (!empty($visit['search_terms'])) {
                    echo filter_link(array('search_terms' => $visit['search_terms']), $visit['search_terms']);
                } else {
                    echo filter_link(array('domain' => $visit['domain']), $visit['domain']);
                }
                echo ' <a href="' . htmlspecialchars($visit['referrer']) . '" rel="external noreferrer" class="goto ext">&rarr;</a>';
            } else {
                echo '<td colspan="3">&nbsp;';
            }
            echo '</tr>';
            $row++;
        }
    }
    echo '</table>';
    echo '<nav class="center wide hide-if-no-js"><a class="ajax" style="display:block; padding: 5px" id="load-more">— ' . __('more') . ' —</a></nav>';
    echo '</div>';
    page_foot();
}