<?php

// Create the new page - then edit all those text files...

//include ("copydir.php");

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

mkdir("../pages/".  $testName ."");

//copyr('tmp', '../pages/'.$testName.'');	


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

$header = $_POST['header'];
$nav = $_POST['nav'];
$tmp = $_POST['tmp'];

$reveal = $_POST['reveal'];

// CODE FOR 2 VARIANTS:

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

// SETTING VARIANT CONTENT

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

$v1_contentTXT2 = "../pages/$testName/title.txt";
$v1_contentHandle2 = fopen($v1_contentTXT2, 'w') or die("can't open file");
$sd2 = "$variant2";
fwrite($v1_contentHandle2, $sd2);
fclose($v1_contentHandle2);

$v1_contentTXT3 = "../pages/$testName/header.txt";
$v1_contentHandle3 = fopen($v1_contentTXT3, 'w') or die("can't open file");
$sd3 = "$header";
fwrite($v1_contentHandle3, $sd3);
fclose($v1_contentHandle3);

$v1_contentTXT4 = "../pages/$testName/nav.txt";
$v1_contentHandle4 = fopen($v1_contentTXT4, 'w') or die("can't open file");
$sd4 = "$nav";
fwrite($v1_contentHandle4, $sd4);
fclose($v1_contentHandle4);

$v1_contentTXT5 = "../pages/$testName/tmp.txt";
$v1_contentHandle5 = fopen($v1_contentTXT5, 'w') or die("can't open file");
$sd5 = "$tmp";
fwrite($v1_contentHandle5, $sd5);
fclose($v1_contentHandle5);

$v1_contentTXT6 = "../pages/$testName/views.txt";
$v1_contentHandle6 = fopen($v1_contentTXT6, 'w') or die("can't open file");
$sd6 = "0";
fwrite($v1_contentHandle6, $sd6);
fclose($v1_contentHandle6);

$v1_contentTXT7 = "../pages/$testName/reveal.txt";
$v1_contentHandle7 = fopen($v1_contentTXT7, 'w') or die("can't open file");
$sd7 = "$reveal";
fwrite($v1_contentHandle7, $sd7);
fclose($v1_contentHandle7);


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