<commit_before><?php

    session_start();

    require_once("database.php");


  if (dirname($_SERVER['PHP_SELF'])=="/") {
    $siteroot ="http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
  }
  else {
    $siteroot ="http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/";
  }

    if($_REQUEST["language"])
    {
        $language = $_REQUEST["language"];
    }
    elseif($storelanguage)
    {
        $language = $storelanguage;
    }

    require_once('language.php');

    try {
        $db = connect();
    } catch (PDOException $e) {
        $db = null;
        $html  = " <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n";
        $html .= "        <head>\n";
        $html .= "            <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"/>\n";
	$html .= "            <link rel=\"shortcut icon\" href=\"favicon.ico\">\n";
	$html .= "            <title>$title_text (v" . $version_text . ")</title>\n";
        $html .= "        </head>\n";
        $html .= "        <body bgcolor=\"$bgcolor\">\n";
        $html .= "            <div align=center>\n";
	$html .= "                $database_fail_text<br>\n";
        $html .= "                <br>\n";
        $html .= "                " . $e->getMessage() . "<br>\n";
        $html .= "                <br>\n";
        $html .= "                <br>\n";
        $html .= "                <br>\n";
        $html .= "                <br>\n";
    }

    if (!is_null($db))
    {
        // Delete trip
        if (isset($_GET['deleteTrip']) && is_numeric($_GET['deleteTrip'])) {
          $tripId = (int)$_GET['deleteTrip'];

            try {
                $db->beginTransaction();
                $db->exec_sql("DELETE FROM `trips` WHERE `ID` = ?", $tripId);
                $db->exec_sql("DELETE FROM `positions` WHERE `FK_Trips_ID` = ?", $tripId);
                $db->commit();
            } catch (Exception $e) {
                $db->rollback();
            }

          header('Location: '.$siteroot);
        }

        $num_users = $db->get_count("users");
        $num_trips = $db->get_count("trips");
        $num_positions = $db->get_count("positions");
        $num_icons = $db->get_count("icons");


        $filter            = $_REQUEST["filter"];
        $trip              = preg_replace("/[^a-zA-Z0-9]/", "", $_REQUEST["trip"]);
        $ID                = $_REQUEST["ID"];
        $username          = $_REQUEST["username"];
        $password          = $_REQUEST["password"];
        $action            = $_REQUEST["action"];
        $storeshowbearings = $_REQUEST["storeshowbearings"];
        $storecrosshair    = $_REQUEST["storecrosshair"];
        $storeclickcenter  = $_REQUEST["storeclickcenter"];
        $storeoverview     = $_REQUEST["storeoverview"];
        $storelanguage     = $_REQUEST["storelanguage"];
        $storeunits        = $_REQUEST["storeunits"];
        $storestartdate    = $_REQUEST["storestartdate"];
        $storeenddate      = $_REQUEST["storeenddate"];
        $startday          = preg_replace("/[^0-9 :\-]/", "", $_REQUEST["startday"]);
        $endday            = preg_replace("/[^0-9 :\-]/", "", $_REQUEST["endday"]);

        if ($action == "form_display" || $custom_view == "yes")
        {

			if($_REQUEST["setcrosshair"])
            {
                $crosshair = "yes";
            }
            elseif($action == "form_display")
            {
                $crosshair = "no";
            }
            else
            {
                $crosshair = $storecrosshair;
            }

            if($_REQUEST["setclickcenter"])
            {
                $clickcenter = "yes";
            }
            elseif($action == "form_display")<commit_msg>Support loading a trip without specifying a user<commit_after><?php

    session_start();

    require_once("database.php");


  if (dirname($_SERVER['PHP_SELF'])=="/") {
    $siteroot ="http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
  }
  else {
    $siteroot ="http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/";
  }

    if($_REQUEST["language"])
    {
        $language = $_REQUEST["language"];
    }
    elseif($storelanguage)
    {
        $language = $storelanguage;
    }

    require_once('language.php');

    try {
        $db = connect();
    } catch (PDOException $e) {
        $db = null;
        $html  = " <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n";
        $html .= "        <head>\n";
        $html .= "            <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"/>\n";
	$html .= "            <link rel=\"shortcut icon\" href=\"favicon.ico\">\n";
	$html .= "            <title>$title_text (v" . $version_text . ")</title>\n";
        $html .= "        </head>\n";
        $html .= "        <body bgcolor=\"$bgcolor\">\n";
        $html .= "            <div align=center>\n";
	$html .= "                $database_fail_text<br>\n";
        $html .= "                <br>\n";
        $html .= "                " . $e->getMessage() . "<br>\n";
        $html .= "                <br>\n";
        $html .= "                <br>\n";
        $html .= "                <br>\n";
        $html .= "                <br>\n";
    }

    if (!is_null($db))
    {
        // Delete trip
        if (isset($_GET['deleteTrip']) && is_numeric($_GET['deleteTrip'])) {
          $tripId = (int)$_GET['deleteTrip'];

            try {
                $db->beginTransaction();
                $db->exec_sql("DELETE FROM `trips` WHERE `ID` = ?", $tripId);
                $db->exec_sql("DELETE FROM `positions` WHERE `FK_Trips_ID` = ?", $tripId);
                $db->commit();
            } catch (Exception $e) {
                $db->rollback();
            }

          header('Location: '.$siteroot);
        }

        $num_users = $db->get_count("users");
        $num_trips = $db->get_count("trips");
        $num_positions = $db->get_count("positions");
        $num_icons = $db->get_count("icons");


        $filter            = $_REQUEST["filter"];
        $trip              = preg_replace("/[^a-zA-Z0-9]/", "", $_REQUEST["trip"]);
        $ID                = $_REQUEST["ID"];
        $username          = $_REQUEST["username"];
        $password          = $_REQUEST["password"];
        $action            = $_REQUEST["action"];
        $storeshowbearings = $_REQUEST["storeshowbearings"];
        $storecrosshair    = $_REQUEST["storecrosshair"];
        $storeclickcenter  = $_REQUEST["storeclickcenter"];
        $storeoverview     = $_REQUEST["storeoverview"];
        $storelanguage     = $_REQUEST["storelanguage"];
        $storeunits        = $_REQUEST["storeunits"];
        $storestartdate    = $_REQUEST["storestartdate"];
        $storeenddate      = $_REQUEST["storeenddate"];
        $startday          = preg_replace("/[^0-9 :\-]/", "", $_REQUEST["startday"]);
        $endday            = preg_replace("/[^0-9 :\-]/", "", $_REQUEST["endday"]);

        if (is_numeric($trip) && !isset($ID))
        {
            $ID = $db->exec_sql("SELECT FK_Users_ID FROM trips WHERE ID = ?",
                                $trip)->fetchColumn();
        }

        if ($action == "form_display" || $custom_view == "yes")
        {

			if($_REQUEST["setcrosshair"])
            {
                $crosshair = "yes";
            }
            elseif($action == "form_display")
            {
                $crosshair = "no";
            }
            else
            {
                $crosshair = $storecrosshair;
            }

            if($_REQUEST["setclickcenter"])
            {
                $clickcenter = "yes";
            }
            elseif($action == "form_display")
{'fraction_non_alphanumeric': 0.19276644863409004, 'fraction_numerical': 0.003334615877901757, 'mean_word_length': 1.6238223418573352, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 57, 'https://': 0, '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': '38322', 'n_tokens_mistral': 2446, 'n_tokens_neox': 2297, 'n_words': 351}