<commit_before><?php
/**
* LoadAvg - Server Monitoring & Analytics
* http://www.loadavg.com
*
* Main index file
* 
* @version SVN: $Id$
* @link https://github.com/loadavg/loadavg
* @author <NAME>
* @copyright 2014 Sputnik7
*
* This file is licensed under the Affero General Public License version 3 or
* later.
*/

require_once '../globals.php';

/* Session */
ob_start(); 
session_start();

/* Initialize LoadAvg */ 
include 'class.LoadAvg.php';
$loadavg = new LoadAvg();

$settings = LoadAvg::$_settings->general;

$settings_file = APP_PATH . '/config/settings.ini';

require_once APP_PATH . '/layout/header.php';

if ( isset( $_GET['check'] ) ) {
	if ( $loadavg->checkWritePermissions( $settings_file ) ) {

		//try to delete installer...

		if ( $loadavg->checkInstaller() ) {
			header("Location: index.php");
		} 
		else 
		{

			$installer_file = HOME_PATH . "/install/index.php";
			$installer_loc = HOME_PATH . "/install";

			echo $installer_file . '<br>';
			echo $installer_loc . '<br>';

			//try to delete it first if we have permissions
			
			unlink($installer_file);
			rmdir($installer_loc);

			if ( $loadavg->checkInstaller() ) {
				header("Location: index.php");
			}
			else
			{ 
			?>

			<div class="well">
				<h3>Secure your installation!</h3>

					<p>For security reasons, you need to delete the <span class="label label-info">/install</span> folder 
					before you can run LoadAvg<br> 
					<br>
					To do this go to the location you installed LoadAvg and type:<br>
					<br>
					<span class="label label-info">rm -rf install</span>
					<br><br>
					LoadAvg will not run until this has been done.
					<br><br>
					After you have removed the install folder hit <span class="label label-info">Check again</span> 
				to login<br><br>
				</p>
				<button class="btn btn-primary" onclick="location.reload();">Check again!</button>
			</div>
			
			<!--
			<script>alert("PLEASE REMOVE install.php FROM YOUR /public FOLDER!");</script>
			-->

			<?php
			require_once APP_PATH . '/layout/footer.php'; 
			exit;
			}
		}
	} else {
		header("Location: " . SCRIPT_ROOT . "/install/index.php?step=1");
	}
} else {
	$loadavg->checkInstall();
}

$loadavg->createFirstLogs();

if ( 
	( isset($_GET['minDate']) && !empty($_GET['minDate']) ) &&
	( isset($_GET['maxDate']) && !empty($_GET['maxDate']) )
	) 
{
	LoadAvg::$period = true;
	LoadAvg::$period_minDate = date("Y-m-d", strtotime($_GET['minDate']));
	LoadAvg::$period_maxDate = date("Y-m-d", strtotime($_GET['maxDate']));
}

$loadavg->setStartTime(); // Setting page load start time

$loaded = LoadAvg::$_settings->general['modules']; 
$logdir = APP_PATH . '/../logs/';

if ($settings['allow_anyone'] == "false" && !$loadavg->isLoggedIn()) {
	include( APP_PATH . '/views/login.php');
} else {
	if (isset($_GET['page']) && file_exists( APP_PATH . '/views/' . $_GET['page'] . '.php' ) ) {
		if ( !$loadavg->isLoggedIn() && $_GET['page'] == "settings" && (isset($settings['allow_anyone']) && $settings['allow_anyone'] == "true")) {
			if (!$loadavg->isLoggedIn()) { include( APP_PATH . '/views/login.php'); }
		} else {
			require_once APP_PATH . '/views/' . $_GET['page'] . '.php';
		}
	} else {
		require_once APP_PATH . '/views/index.php';
	}
}

$loadavg->setFinishTime(); // Setting page load finish time

$page_load = $loadavg->getPageLoadTime(); // Calculating page load time


require_once APP_PATH . '/layout/footer.php'; ?><commit_msg>Updates and final revisions for 2.0 release<commit_after><?php
/**
* LoadAvg - Server Monitoring & Analytics
* http://www.loadavg.com
*
* Main index file
* 
* @version SVN: $Id$
* @link https://github.com/loadavg/loadavg
* @author <NAME>
* @copyright 2014 Sputnik7
*
* This file is licensed under the Affero General Public License version 3 or
* later.
*/

require_once '../globals.php';

/* Session */
ob_start(); 
session_start();

/* Initialize LoadAvg */ 
include 'class.LoadAvg.php';
$loadavg = new LoadAvg();

$settings = LoadAvg::$_settings->general;

$settings_file = APP_PATH . '/config/settings.ini';

require_once APP_PATH . '/layout/header.php';

if ( isset( $_GET['check'] ) ) {
	if ( $loadavg->checkWritePermissions( $settings_file ) ) {

		//try to delete installer...
		if ( $loadavg->checkInstaller() ) {
			header("Location: index.php");
		} 
		else 
		{

			$installer_file = HOME_PATH . "/install/index.php";
			$installer_loc = HOME_PATH . "/install/";

			//try to delete it first if we have permissions
			unlink($installer_file);
			rmdir($installer_loc);

			if ( $loadavg->checkInstaller() ) {
				header("Location: index.php");
			}
			else
			{ 
			?>

			<div class="well">
				<h3>Secure your installation!</h3>

					<p>For security reasons, you need to delete the <span class="label label-info">/install</span> folder 
					before you can run LoadAvg<br> 
					<br>
					To do this go to the location you installed LoadAvg and type:<br>
					<br>
					<span class="label label-info">rm -rf install</span>
					<br><br>
					LoadAvg will not run until this has been done.
					<br><br>
					After you have removed the install folder hit <span class="label label-info">Check again</span> 
				to login<br><br>
				</p>
				<button class="btn btn-primary" onclick="location.reload();">Check again!</button>
			</div>
			
			<!--
			<script>alert("PLEASE REMOVE install.php FROM YOUR /public FOLDER!");</script>
			-->

			<?php
			require_once APP_PATH . '/layout/footer.php'; 
			exit;
			}
		}
	} else {
		header("Location: " . SCRIPT_ROOT . "/install/index.php?step=1");
	}
} else {
	$loadavg->checkInstall();
}

$loadavg->createFirstLogs();

if ( 
	( isset($_GET['minDate']) && !empty($_GET['minDate']) ) &&
	( isset($_GET['maxDate']) && !empty($_GET['maxDate']) )
	) 
{
	LoadAvg::$period = true;
	LoadAvg::$period_minDate = date("Y-m-d", strtotime($_GET['minDate']));
	LoadAvg::$period_maxDate = date("Y-m-d", strtotime($_GET['maxDate']));
}

$loadavg->setStartTime(); // Setting page load start time

$loaded = LoadAvg::$_settings->general['modules']; 
$logdir = APP_PATH . '/../logs/';

if ($settings['allow_anyone'] == "false" && !$loadavg->isLoggedIn()) {
	include( APP_PATH . '/views/login.php');
} else {
	if (isset($_GET['page']) && file_exists( APP_PATH . '/views/' . $_GET['page'] . '.php' ) ) {
		if ( !$loadavg->isLoggedIn() && $_GET['page'] == "settings" && (isset($settings['allow_anyone']) && $settings['allow_anyone'] == "true")) {
			if (!$loadavg->isLoggedIn()) { include( APP_PATH . '/views/login.php'); }
		} else {
			require_once APP_PATH . '/views/' . $_GET['page'] . '.php';
		}
	} else {
		require_once APP_PATH . '/views/index.php';
	}
}

$loadavg->setFinishTime(); // Setting page load finish time

$page_load = $loadavg->getPageLoadTime(); // Calculating page load time


require_once APP_PATH . '/layout/footer.php'; ?>
{'fraction_non_alphanumeric': 0.18900646678424457, 'fraction_numerical': 0.0029394473838918285, 'mean_word_length': 3.613559322033898, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 91, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6152912', 'n_tokens_mistral': 2654, 'n_tokens_neox': 2363, 'n_words': 528}