<?php

// Load up all dem variable... eh... let's do that...

$testName = $_POST['testName'];
$testName = str_replace (" ", "", $testName);

$runTime = $_POST['runTime'];

// CODE FOR 2 VARIANTS:

$variant1 = $_POST['variant1'];
$variant2 = $_POST['variant2'];

// Make a new folder for the created goodness...

mkdir("../tests/$testName");
mkdir("../tests/$testName/stats");

// Make txt file for the runTime number...

$runTimeTXT = "../tests/$testName/runTime.txt";
$runTimeHandle = fopen($runTimeTXT, 'w') or die("can't open file");
$sd1 = "$runTime";
fwrite($runTimeHandle, $sd1);
fclose($runTimeHandle);

// Make txt file for the variant TYPE (2, 4, 6)...

$variantTypeTXT = "../tests/$testName/variantType.txt";
$variantTypeHandle = fopen($variantTypeTXT, 'w') or die("can't open file");
$sd10 = "2";
fwrite($variantTypeHandle, $sd10);
fclose($variantTypeHandle);

// Setting up the stats txt files... AB -  Landing - Download - v1  - v2

$abTXT = "../tests/$testName/stats/ab.txt";
$abHandle = fopen($abTXT, 'w') or die("can't open file");
$sd2 = "1";
fwrite($abHandle, $sd2);
fclose($abHandle);

$siteTXT = "../tests/$testName/stats/site.txt";
$siteHandle = fopen($siteTXT, 'w') or die("can't open file");
$sd3 = "1";
fwrite($siteHandle, $sd3);
fclose($siteHandle);

$downloadTXT = "../tests/$testName/stats/download.txt";
$downloadHandle = fopen($downloadTXT, 'w') or die("can't open file");
$sd4 = "0";
fwrite($downloadHandle, $sd4);
fclose($downloadHandle);

// V1 - V2

$v1TXT = "../tests/$testName/stats/v1.txt";
$v1Handle = fopen($v1TXT, 'w') or die("can't open file");
$sd5 = "0";
fwrite($v1Handle, $sd5);
fclose($v1Handle);

$v2TXT = "../tests/$testName/stats/v2.txt";
$v2Handle = fopen($v2TXT, 'w') or die("can't open file");
$sd6 = "0";
fwrite($v2Handle, $sd6);
fclose($v2Handle);

// SETTING VARIANT CONTENT

$v1_contentTXT = "../tests/$testName/v1.txt";
$v1_contentHandle = fopen($v1_contentTXT, 'w') or die("can't open file");
$sd7 = "$variant1";
fwrite($v1_contentHandle, $sd7);
fclose($v1_contentHandle);

$v2_contentTXT = "../tests/$testName/v2.txt";
$v2_contentHandle = fopen($v2_contentTXT, 'w') or die("can't open file");
$sd8 = "$variant2";
fwrite($v2_contentHandle, $sd8);
fclose($v2_contentHandle);

header('Location: ../index.php');
?>