<commit_before><?php

require 'libs/Smarty.class.php';				// templating engine
$smarty = new Smarty;

include_once('includes/db.inc.php');			// DB connectivity
include_once('includes/models.inc.php');		// Reusable db code
include_once('includes/auth.inc.php');			// user authentication
include_once('includes/helpers.inc.php');		// misc helpers

stop_sql_injection();							// sanitize request data

if (loggedIn()){
	$template = 'home.html';
	$smarty->assign('subtitle', 'home');
} else {
	$template = 'login.html';					// let default page be login if not authenticated
	$smarty->assign('subtitle', 'Login');
}

if (!isset($_GET['page']))
	$page = '';
else
	$page = $_GET['page'];

switch ($page){
	case 'confirm':
		checkLogin();
		if (loggedIn()){
			header("Location: /index.php?page=home");
		} else {
			$smarty->assign('login_error', 'Invalid username or password.');
		}
		break;
	
	case 'home':
		if (loggedIn()){
			$template = 'home.html';
			$smarty->assign('subtitle', 'Home');
		}
		break;
	
	case 'logout':
		logout();
		header("Location: /index.php");
		break;
	
	case 'reportNew':
		if (loggedIn()){
			$template = 'addedit.html';
			$smarty->assign('subtitle','Add new bug');
			$smarty->assign('scripts', array('/static/scripts/addnew.js'));
		}
		break;
	
	case 'addNew':
		if (loggedIn()){
			addNewBug();
			$template = 'addedit.html';
			$smarty->assign('subtitle','Add new bug');
			$smarty->assign('scripts', array('/static/scripts/addnew.js'));
		}
		break;
		
	case 'list':
		if (loggedIn()){
			$template = 'buglist.html';
			$smarty->assign('subtitle','bug list');
		}
		break;
}

session_to_smarty($smarty);							// move all session data to be available in views
$smarty->display('header.html');				// concatenate other common parts together
$smarty->display($template);
$smarty->display('footer.html');
?><commit_msg>preparing the buglist page<commit_after><?php

require 'libs/Smarty.class.php';				// templating engine
$smarty = new Smarty;

include_once('includes/db.inc.php');			// DB connectivity
include_once('includes/models.inc.php');		// Reusable db code
include_once('includes/auth.inc.php');			// user authentication
include_once('includes/helpers.inc.php');		// misc helpers

stop_sql_injection();							// sanitize request data

if (loggedIn()){
	$template = 'home.html';
	$smarty->assign('subtitle', 'home');
} else {
	$template = 'login.html';					// let default page be login if not authenticated
	$smarty->assign('subtitle', 'Login');
}

if (!isset($_GET['page']))
	$page = '';
else
	$page = $_GET['page'];

switch ($page){
	case 'confirm':
		checkLogin();
		if (loggedIn()){
			header("Location: /index.php?page=home");
		} else {
			$smarty->assign('login_error', 'Invalid username or password.');
		}
		break;
	
	case 'home':
		if (loggedIn()){
			$template = 'home.html';
			$smarty->assign('subtitle', 'Home');
		}
		break;
	
	case 'logout':
		logout();
		header("Location: /index.php");
		break;
	
	case 'reportNew':
		if (loggedIn()){
			$template = 'addedit.html';
			$smarty->assign('subtitle','Add new bug');
			$smarty->assign('scripts', array('/static/scripts/addnew.js'));
		}
		break;
	
	case 'addNew':
		if (loggedIn()){
			if (($bug_id = addNewBug()) > 0){
				header("Location: /index.php?page=list&highlight=$bug_id");
			}
			// otherwise case never comes as it dies in addNewBug itself
		}
		break;
		
	case 'list':
		if (loggedIn()){
			$template = 'buglist.html';
			$smarty->assign('subtitle','bug list');
			$smarty->assign('buglist',getAllBugList());
		}
		break;
}

session_to_smarty($smarty);							// move all session data to be available in views
$smarty->display('header.html');				// concatenate other common parts together
$smarty->display($template);
$smarty->display('footer.html');
?>
{'fraction_non_alphanumeric': 0.1937367303609342, 'fraction_numerical': 0.0002653927813163482, 'mean_word_length': 4.025333333333333, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3124684', 'n_tokens_mistral': 1474, 'n_tokens_neox': 1305, 'n_words': 278}