<commit_before>import sys, os

class TimeMachineLogic(object):
	
    def __init__(self,histo_step):

	self.output = """<?php

	# check if stepping is set, otherwise use default
	if (isset($_GET["s"]) && $_GET["s"] != "") { $histo_step = $_GET["s"];}
	else { $histo_step = '""" + histo_step + """';}

	# function to reset the date/time input variables from previous views
	# used by the TimeMachineControler part
	function reset_time () {
	    $_GET["date"] = "";
	    $_GET["time"] = "";
	}

	# define current date / time from server time
	$server_time = $_SERVER['REQUEST_TIME'];

	# read DN if possible
	if (isset($_SERVER["SSL_CLIENT_CERT"]))
	{
	    $cert=openssl_x509_parse($_SERVER["SSL_CLIENT_CERT"]);
	    $client_dn=$cert["name"];
	}
	else if(isset($_SERVER["SSL_CLIENT_S_DN"]))
	{
	    $client_dn=$_SERVER["SSL_CLIENT_S_DN"];
	}
	else
	{
	    $client_dn="";
	}
   

	# define empty error message string for wrong date / time input
	$time_error_message = "";

	# read $_GET["..."] variables (from previous views)
	if (isset($_GET["date"]) && isset($_GET["time"]) && $_GET["date"] != "" && $_GET["time"] != "") {

	    # variable to disable the auto reload on history view
	    $historyview = "true";
	
	    # build timestamp array
	    $ta = date_parse($_GET["date"] . " " . $_GET["time"]);

	    # check if date / time input has the right format
	    # if the input is ok, define new $timestamp variable for the SQL queries
	    if ($ta["error_count"] == 0 && checkdate($ta["month"],$ta["day"],$ta["year"]) == 1 ) {
		$date_string = $_GET["date"];
		$time_string = $_GET["time"];
		$timestamp = mktime( $ta["hour"],$ta["minute"],0,$ta["month"],$ta["day"],$ta["year"] );

		# for future inputs, print error message and go back to current server time
		if ($timestamp - $server_time > 0) {
		    $time_error_message = '<td><span style="color:red;">I am not an oracle!!</span></td>';
		    $date_string = date("Y-m-d",$server_time);
		    $time_string = date("H:i",$server_time);
		    $timestamp = $server_time;
		}

		# if the input has a wrong format, take current servertime, define $error_message string for output
	    } else {
		$time_error_message = '<td><span style="color:red;">Wrong Date/Time Format!!</span></td>';
	    	$date_string = date("Y-m-d",$server_time);
		$time_string = date("H:i",$server_time);
		$timestamp = $server_time;
	    }
	}

	# if $_GET["..."] variables are empty (first call of the website)
	# take the current servertime as $timestamp variable for the SQL queries
	else {
	    $date_string = date("Y-m-d",$server_time);
	    $time_string = date("H:i",$server_time);
	    $timestamp = $server_time;
	}

	# if the chosen timestamp is "older" then a half hour (1800 seconds)
	# define a RED colored time string for the time bar output
	if ($server_time - $timestamp < 1800) {
	    $date_message = '<span>' . date("D, d. M Y", $timestamp) . '</span>';
	    $date_message_short = '<span>' . date("d. M Y", $timestamp) . '</span>';
	    $time_message = '<span style="font-style: italic;">' . date("H:i", $timestamp) . ' h</span>';
	}
	else {
	    $date_message = '<span style="color:red;">' . date("D, d. M Y", $timestamp) . '</span>';
	    $date_message_short = '<span style="color:red;">' . date("d. M Y", $timestamp) . '</span>';
	    $time_message = '<span style="color:red;font-style: italic;">' . date("H:i", $timestamp) . ' h</span>';
	}

	?>"""<commit_msg>Some cosmetics<commit_after>import sys, os

class TimeMachineLogic(object):
	
    def __init__(self,histo_step):

	self.output = """<?php

	# check if stepping is set, otherwise use default
	if (isset($_GET["s"]) && $_GET["s"] != "") { $histo_step = $_GET["s"];}
	else { $histo_step = '""" + histo_step + """';}

	# function to reset the date/time input variables from previous views
	# used by the TimeMachineControler part
	function reset_time () {
	    $_GET["date"] = "";
	    $_GET["time"] = "";
	}

	# define current date / time from server time
	$server_time = $_SERVER['REQUEST_TIME'];

	# read DN if possible
	if (isset($_SERVER["SSL_CLIENT_CERT"]))
	{
	    $cert=openssl_x509_parse($_SERVER["SSL_CLIENT_CERT"]);
	    $client_dn=$cert["name"];
	}
	else if(isset($_SERVER["SSL_CLIENT_S_DN"]))
	{
	    $client_dn=$_SERVER["SSL_CLIENT_S_DN"];
	}
	else
	{
	    $client_dn="";
	}
   

	# define empty error message string for wrong date / time input
	$time_error_message = "";

	# read $_GET["..."] variables (from previous views)
	if (isset($_GET["date"]) && isset($_GET["time"]) && $_GET["date"] != "" && $_GET["time"] != "") {

	    # variable to disable the auto reload on history view
	    $historyview = "true";
	
	    # build timestamp array
	    $ta = date_parse($_GET["date"] . " " . $_GET["time"]);

	    # check if date / time input has the right format
	    # if the input is ok, define new $timestamp variable for the SQL queries
	    if ($ta["error_count"] == 0 && checkdate($ta["month"],$ta["day"],$ta["year"]) == 1 ) {
		$date_string = $_GET["date"];
		$time_string = $_GET["time"];
		$timestamp = mktime( $ta["hour"],$ta["minute"],0,$ta["month"],$ta["day"],$ta["year"] );

		# for future inputs, print error message and go back to current server time
		if ($timestamp - $server_time > 0) {
		    $time_error_message = '<td><span style="color:red;">I am not an oracle!!</span></td>';
		    $date_string = date("Y-m-d",$server_time);
		    $time_string = date("H:i",$server_time);
		    $timestamp = $server_time;
		}

		# if the input has a wrong format, take current servertime, define $error_message string for output
	    } else {
		$time_error_message = '<td><span style="color:red;">Wrong Date/Time Format!!</span></td>';
	    	$date_string = date("Y-m-d",$server_time);
		$time_string = date("H:i",$server_time);
		$timestamp = $server_time;
	    }
	}

	# if $_GET["..."] variables are empty (first call of the website)
	# take the current servertime as $timestamp variable for the SQL queries
	else {
	    $date_string = date("Y-m-d",$server_time);
	    $time_string = date("H:i",$server_time);
	    $timestamp = $server_time;
	}

	# if the chosen timestamp is "older" then a half hour (1800 seconds)
	# define a RED colored time string for the time bar output
	if ($server_time - $timestamp < 1800) {
	    $date_message = '<span>' . date("D, d. M Y", $timestamp) . '</span>';
	    $date_message_short = '<span>' . date("d. M Y", $timestamp) . '</span>';
	    $time_message = '<span>' . date("H:i", $timestamp) . '</span>';
	}
	else {
	    $date_message = '<span style="color:red;">' . date("D, d. M Y", $timestamp) . '</span>';
	    $date_message_short = '<span style="color:red;">' . date("d. M Y", $timestamp) . '</span>';
	    $time_message = '<span style="color:red;">' . date("H:i", $timestamp) . '</span>';
	}

	?>"""
{'fraction_non_alphanumeric': 0.1929798578199052, 'fraction_numerical': 0.004443127962085308, 'mean_word_length': 3.8478104809763103, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 47, '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': '5701146', 'n_tokens_mistral': 2411, 'n_tokens_neox': 2258, 'n_words': 594}