quickvm.php 16.7 KB
Newer Older
Leigh B Stoller's avatar
Leigh B Stoller committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
<?php
#
# Copyright (c) 2000-2013 University of Utah and the Flux Group.
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
#
chdir("..");
include("defs.php3");
include_once("osinfo_defs.php");
include_once("geni_defs.php");
28
chdir("apt");
Leigh B Stoller's avatar
Leigh B Stoller committed
29
include("quickvm_sup.php");
Leigh B Stoller's avatar
Leigh B Stoller committed
30
$dblink = GetDBLink("sa");
Leigh B Stoller's avatar
Leigh B Stoller committed
31 32 33 34 35 36 37

#
# Verify page arguments.
#
$optargs = OptionalPageArguments("create",      PAGEARG_STRING,
				 "username",    PAGEARG_STRING,
				 "email",	PAGEARG_STRING,
Leigh B Stoller's avatar
Leigh B Stoller committed
38
				 "profile",     PAGEARG_STRING,
Leigh B Stoller's avatar
Leigh B Stoller committed
39 40
				 "stuffing",    PAGEARG_STRING,
				 "verify",      PAGEARG_STRING,
Leigh B Stoller's avatar
Leigh B Stoller committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
				 "sshkey",	PAGEARG_STRING,
				 "ajax_request",  PAGEARG_BOOLEAN,
				 "ajax_method",   PAGEARG_STRING,
				 "ajax_argument", PAGEARG_STRING);

#
# Deal with ajax requests.
#
if (isset($ajax_request)) {
    if ($ajax_method == "getprofile") {
	$profile_name = addslashes($ajax_argument);
	$query_result =
	    DBQueryWarn("select * from quickvm_rspecs ".
			"where name='$profile_name'", $dblink);

	if (!$query_result || !mysql_num_rows($query_result)) {
	    SPITAJAX_ERROR(1, "No such profile!");
	    exit();
	}
	$row = mysql_fetch_array($query_result);
	
	SPITAJAX_RESPONSE(array('rspec' => $row['rspec'],
				'name'  => $row['name'],
				'description' => $row['description']));
    }
    exit();
}
Leigh B Stoller's avatar
Leigh B Stoller committed
68 69 70 71 72

# Form defaults.
$username_default = "Pick a user name";
$email_default    = "Your email address";
$sshkey_default   = "Your SSH public key";
Leigh B Stoller's avatar
Leigh B Stoller committed
73 74
$profile_default  = "UBUNTU12-64-STD";
$profile_array    = array();
Leigh B Stoller's avatar
Leigh B Stoller committed
75

Leigh B Stoller's avatar
Leigh B Stoller committed
76 77 78 79 80
$query_result =
    DBQueryFatal("select * from quickvm_rspecs", $dblink);
while ($row = mysql_fetch_array($query_result)) {
    $profile_array[$row["name"]] = $row["name"];
}
Leigh B Stoller's avatar
Leigh B Stoller committed
81

Leigh B Stoller's avatar
Leigh B Stoller committed
82
function SPITFORM($username, $email, $sshkey, $profile, $newuser, $errors)
Leigh B Stoller's avatar
Leigh B Stoller committed
83 84 85
{
    global $TBBASE, $TBMAIL_OPS;
    global $username_default, $email_default, $sshkey_default;
Leigh B Stoller's avatar
Leigh B Stoller committed
86
    global $profile_default, $profile_array;
Leigh B Stoller's avatar
Leigh B Stoller committed
87 88 89 90

    $username_value   = "";
    $email_value      = "";
    $sshkey_value     = "";
Leigh B Stoller's avatar
Leigh B Stoller committed
91
    $profile_value    = "";
Leigh B Stoller's avatar
Leigh B Stoller committed
92 93 94
    $username_error   = "";
    $email_error      = "";
    $sshkey_error     = "";
Leigh B Stoller's avatar
Leigh B Stoller committed
95
    $profile_error    = "";
Leigh B Stoller's avatar
Leigh B Stoller committed
96 97 98 99 100 101 102 103 104 105 106
    $internal_error   = null;

    if (isset($username) && $username != "") {
	$username_value = CleanString($username);
    }
    if (isset($email) && $email != "") {
	$email_value = CleanString($email);
    }
    if (isset($sshkey) && $sshkey != "") {
	$sshkey_value = CleanString($sshkey);
    }
Leigh B Stoller's avatar
Leigh B Stoller committed
107 108
    if (isset($profile) && $profile != "") {
	$profile_value = CleanString($profile);
Leigh B Stoller's avatar
Leigh B Stoller committed
109 110 111 112 113 114 115 116 117 118 119
    }
    if ($errors) {
	while (list ($name, $message) = each ($errors)) {
	# XSS prevention.
	    $message = CleanString($message);
	    if ($name == "username")
		$username_error = $message;
	    elseif ($name == "email")
		$email_error = $message;
	    elseif ($name == "sshkey")
		$sshkey_error = $message;
Leigh B Stoller's avatar
Leigh B Stoller committed
120 121
	    elseif ($name == "profile")
		$profile_error = $message;
Leigh B Stoller's avatar
Leigh B Stoller committed
122 123 124 125 126
	    elseif ($name == "internal") {
		$internal_error = $message;
	    }
	}
    }
Leigh B Stoller's avatar
Leigh B Stoller committed
127
    SPITHEADER(1);
Leigh B Stoller's avatar
Leigh B Stoller committed
128 129 130 131 132

    if ($internal_error) {
	echo "<center><h2>$internal_error</h2></center><br>\n";
    }

133
    echo "<div class='row'>
Leigh B Stoller's avatar
Leigh B Stoller committed
134
          <div class='col-lg-6  col-lg-offset-3
135
                      col-md-6  col-md-offset-3
Leigh B Stoller's avatar
Leigh B Stoller committed
136 137
                      col-sm-8  col-sm-offset-2
                      col-xs-12 col-xs-offset-0'>\n";
138
    echo "<form id='quickvm_form' role='form'
Leigh B Stoller's avatar
Leigh B Stoller committed
139
            method='post' action='quickvm.php'>\n";
140 141 142 143 144 145
    echo "<div class='panel panel-default'>
           <div class='panel-heading'>
              <h3 class='panel-title'>
                 Create an Experiment</h3></div>
           <div class='panel-body'>
            <div class='form-group'>
Leigh B Stoller's avatar
Leigh B Stoller committed
146 147
                <input name='username' id='username'
                       value='$username_value'
148
                       class='form-control'
Leigh B Stoller's avatar
Leigh B Stoller committed
149
                       placeholder='$username_default' autofocus type='text'>
150
		<label style='color: red'
Leigh B Stoller's avatar
Leigh B Stoller committed
151 152
                       for='username'>$username_error</label>
            </div>
153 154
            <div class='form-group'>
                <input name='email' id='email' type='text'
Leigh B Stoller's avatar
Leigh B Stoller committed
155
                       value='$email_value'
156
                       class='form-control'
Leigh B Stoller's avatar
Leigh B Stoller committed
157
                       placeholder='$email_default' type='text' />
158
		<label 
Leigh B Stoller's avatar
Leigh B Stoller committed
159 160 161
                       style='color: red'
                       for='email'>$email_error</label>
            </div>
162
            <div class='form-group'>
Leigh B Stoller's avatar
Leigh B Stoller committed
163 164
                <textarea id='sshkey' name='sshkey'
                          placeholder='$sshkey_default'
165
                          class='form-control'
Leigh B Stoller's avatar
Leigh B Stoller committed
166
                          rows=4 cols=45>$sshkey_value</textarea>
167
		<label
Leigh B Stoller's avatar
Leigh B Stoller committed
168 169 170
                       style='color: red'
                       for='sshkey'>$sshkey_error</label>
            </div>
171
            <div class='form-group'>
Leigh B Stoller's avatar
Leigh B Stoller committed
172 173 174
                <select class='pull-left' id='profile_name'
                        name='profile'
                        onChange='ShowProfile(0);'>
Leigh B Stoller's avatar
Leigh B Stoller committed
175
                <option value=''>Select Profile</option>\n";
Leigh B Stoller's avatar
Leigh B Stoller committed
176
    while (list ($id, $title) = each ($profile_array)) {
Leigh B Stoller's avatar
Leigh B Stoller committed
177 178
	$selected = "";
	
Leigh B Stoller's avatar
Leigh B Stoller committed
179
	if ($profile_value == $id)
Leigh B Stoller's avatar
Leigh B Stoller committed
180 181 182 183 184
	    $selected = "selected";
	
	echo "<option $selected value='$id'>$title </option>\n";
    }
    echo "       </select>
185
	        <label
Leigh B Stoller's avatar
Leigh B Stoller committed
186
                       style='color: red'
Leigh B Stoller's avatar
Leigh B Stoller committed
187
                       for='profile'>$profile_error</label>
Leigh B Stoller's avatar
Leigh B Stoller committed
188
            </div>
189 190 191 192 193
            <button class='btn btn-primary pull-right'
	            type='submit' name='create'>Create!
	          </button>
            <br> 
            <button class='btn btn-primary btn-xs pull-left'
Leigh B Stoller's avatar
Leigh B Stoller committed
194 195 196
	            type='button' name='reset'
                    onclick='formReset(); return false;'>
                    Reset Form</button>
197 198 199
        </div>
        </div>
        </div>
Leigh B Stoller's avatar
Leigh B Stoller committed
200 201
        </div>\n";

Leigh B Stoller's avatar
Leigh B Stoller committed
202 203
    if (1) {
    echo "<!-- This is the user verify modal -->
204 205 206 207 208 209 210 211 212
          <div id='working' class='modal fade'>
            <div class='modal-dialog'>
            <div class='modal-content'>
               <div class='modal-header'>
                <button type='button' class='close' data-dismiss='modal'
                   aria-hidden='true'>&times;</button>
                <h3>Important</h3>
               </div>
               <div class='modal-body'>
Leigh B Stoller's avatar
Leigh B Stoller committed
213 214 215 216 217
                    <p>Check your email for a verification code, and
                       enter it here:</p>
                        <input name='verify'
                               placeholder='Verification code'
                               autofocus type='text' />
218
                        <button class='btn btn-primary'
Leigh B Stoller's avatar
Leigh B Stoller committed
219
                            type='submit' name='create'>
220 221 222
                            Create</button>
               </div>
            </div>
Leigh B Stoller's avatar
Leigh B Stoller committed
223 224
            </div>
         </div>\n";
Leigh B Stoller's avatar
Leigh B Stoller committed
225
    }
Leigh B Stoller's avatar
Leigh B Stoller committed
226 227 228 229 230 231 232 233

    if ($newuser) {
	if (is_string($newuser)) {
	    $stuffing = $newuser;
	}
	else {
	    $stuffing = substr(GENHASH(), 0, 16);
	}
Leigh B Stoller's avatar
Leigh B Stoller committed
234 235 236
	mail($email, "Confirm your email to create your Experiment",
	     "Here is your user verification code. Please copy and\n".
	     "paste this code into the box on the experiment page.\n\n".
Leigh B Stoller's avatar
Leigh B Stoller committed
237 238 239 240 241 242
	     "      $stuffing\n",
	     "From: $TBMAIL_OPS");
	echo "<input type='hidden' name='stuffing' value='$stuffing' />";
    }
    echo "</form>\n";

Leigh B Stoller's avatar
Leigh B Stoller committed
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
    echo "<!-- This is the topology view modal -->
          <div id='quickvm_topomodal' class='modal fade'>
            <div class='modal-dialog'  id='showtopo_dialog'>
            <div class='modal-content'>
               <div class='modal-header'>
                <button type='button' class='close' data-dismiss='modal'
                   aria-hidden='true'>&times;</button>
                <span id='showtopo_title'></span>
               </div>
               <div class='modal-body'>
                 <!-- This topo diagram goes inside this div -->
                 <div class='panel panel-default'
                            id='showtopo_container'>
                  <div class='panel-body'>
                   <div id='showtopo_div'></div>
                  </div>
                 </div>
	         <div id='scrollright'
                     class='pull-right' style='cursor: pointer; ".
	           "margin-bottom: 0px; margin-right: 5px;'>
                   <span class='glyphicon glyphicon-arrow-right'></span>
                 </div>
                 <div id='scrollleft'
                     class='pull-left' style='cursor: pointer; ".
	            "margin-bottom: 0px; margin-right: 5px;'>
                  <span class='glyphicon glyphicon-arrow-left'></span>
                 </div>
               </div>
               <div class='modal-footer'>
                 <span class='pull-left' id='showtopo_description'></span>
                 <div class='pull-right'>
                   <button id='showtopo_select'
                         class='btn btn-primary btn-xs'
                         type='submit' name='select'>
                            Select</button>
                 </div>
               </div>
            </div>
            </div>
         </div>\n";

    echo "<SCRIPT LANGUAGE=JavaScript>
               window.onload = InitProfileSelector;
          </SCRIPT>\n";
    echo "<script src='d3.v3.js'></script>\n";
Leigh B Stoller's avatar
Leigh B Stoller committed
288
    echo "<SCRIPT LANGUAGE=JavaScript>\n";
Leigh B Stoller's avatar
Leigh B Stoller committed
289
    
Leigh B Stoller's avatar
Leigh B Stoller committed
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
    if ($newuser) {
	echo "ShowModal('#working');\n";
    }
    echo "function formReset()
          {
              resetForm($('#quickvm_form'));
          }
          </SCRIPT>\n";
}

if (!isset($create)) {
    #
    # Look for cookie that tells us who the user is. 
    #
    $username = null;
    $email    = null;
Leigh B Stoller's avatar
Leigh B Stoller committed
306
    $sshkey   = null;
Leigh B Stoller's avatar
Leigh B Stoller committed
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352
    
    if (isset($_COOKIE['quickvm_user'])) {
	$geniuser = GeniUser::Lookup("sa", $_COOKIE['quickvm_user']);
	if ($geniuser) {
	    #
	    # Look for existing quickvm. User not allowed to create
	    # another one.
	    #
	    $quickvm = QuickVM::LookupByCreator($geniuser->uuid());
	    if ($quickvm && $quickvm->status() != "terminating") {
		header("Location: quickvm_status.php?uuid=" . $quickvm->uuid());
		return;
	    }
	    $username = $geniuser->name();
	    $email    = $geniuser->email();
	    $sshkey   = $geniuser->SSHKey();
	}
    }
    SPITFORM($username, $email, $sshkey, null, false, null);
    SPITFOOTER();
    return;
}
#
# Otherwise, must validate and redisplay if errors
#
$errors = array();
$args   = array();

if (!isset($email) || $email == "" || $email == $email_default) {
    $errors["email"] = "Missing Field";
}
elseif (! TBvalid_email($email)) {
    $errors["email"] = TBFieldErrorString();
}

if (!isset($username) || $username == "" || $username == $username_default) {
    $errors["username"] = "Missing Field";
}
elseif (! TBvalid_uid($username)) {
    $errors["username"] = TBFieldErrorString();
}
elseif (User::LookupByUid($username)) {
    # Do not allow uid overlap with real users.
    $errors["username"] = "Already in use";
}

Leigh B Stoller's avatar
Leigh B Stoller committed
353 354
if (!isset($profile) || $profile == "") {
    $errors["profile"] = "No selection made";
Leigh B Stoller's avatar
Leigh B Stoller committed
355
}
Leigh B Stoller's avatar
Leigh B Stoller committed
356 357
elseif (! array_key_exists($profile, $profile_array)) {
    $errors["profile"] = "Invalid Profile: $profile";
Leigh B Stoller's avatar
Leigh B Stoller committed
358
}
Leigh B Stoller's avatar
Leigh B Stoller committed
359 360
elseif (! in_array($profile, $profile_array)) {
    $errors["profile"] = "Nonexistant Profile: $profile";
Leigh B Stoller's avatar
Leigh B Stoller committed
361 362 363
}

if (count($errors)) {
Leigh B Stoller's avatar
Leigh B Stoller committed
364
    SPITFORM($username, $email, $sshkey, $profile, false, $errors);
Leigh B Stoller's avatar
Leigh B Stoller committed
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
    SPITFOOTER();
    return;
}

#
# More sanity checks. 
#
$exists = GeniUser::LookupByEmail("sa", $email);
if ($exists) {
    if ($exists->name() != $username) {    
	$errors["email"] = "Already in use by another user";
	unset($exists);
    }
}
# Existing users are allowed to resuse their ssh key, but can supply
# a new one if they want.
if (!isset($sshkey) || $sshkey == "" || $sshkey == $sshkey_default) {
    if (!$exists) {
	$errors["sshkey"] = "Missing Field";
    }
}
else {
    $args["sshkey"] = $sshkey;
}

if (count($errors)) {
Leigh B Stoller's avatar
Leigh B Stoller committed
391
    SPITFORM($username, $email, $sshkey, $profile, false, $errors);
Leigh B Stoller's avatar
Leigh B Stoller committed
392 393 394 395 396
    SPITFOOTER();
    return;
}
$args["username"] = $username;
$args["email"]    = $email;
Leigh B Stoller's avatar
Leigh B Stoller committed
397
$args["profile"]  = $profile;
Leigh B Stoller's avatar
Leigh B Stoller committed
398 399 400 401 402

#
# See if user exists and is verified. We send email with a code, which
# they have to paste back into a box we add to the form. See above.
#
Leigh B Stoller's avatar
Leigh B Stoller committed
403 404 405 406 407 408 409
# We also get here if the user exists, but the browser did not have
# the tokens, as will happen if switching to another browser. We
# force the user to repeat the verification with the same code we
# have stored in the DB.
#
if (!$exists || !isset($_COOKIE['quickvm_authkey']) ||
    $_COOKIE['quickvm_authkey'] != $exists->auth_token()) {
Leigh B Stoller's avatar
Leigh B Stoller committed
410 411
    if (isset($stuffing) && $stuffing != "") {
	if (! (isset($verify) && $verify == $stuffing)) {
Leigh B Stoller's avatar
Leigh B Stoller committed
412
	    SPITFORM($username, $email, $sshkey, $profile, $stuffing, $errors);
Leigh B Stoller's avatar
Leigh B Stoller committed
413 414 415
	    SPITFOOTER();
	    return;
	}
Leigh B Stoller's avatar
Leigh B Stoller committed
416 417 418 419 420 421 422 423 424 425 426 427
	#
	# If this is an existing user and they give us the right code,
	# we can check again for an existing VM and redirect to the
	# status page, like we do above.
	#
	if ($exists) {
	    $quickvm = QuickVM::LookupByCreator($exists->uuid());
	    if ($quickvm && $quickvm->status() != "terminating") {
		header("Location: quickvm_status.php?uuid=" . $quickvm->uuid());
		return;
	    }
	}
Leigh B Stoller's avatar
Leigh B Stoller committed
428 429 430 431
	# Pass to backend to save in user object.
	$args["auth_token"] = $stuffing;
    }
    else {
Leigh B Stoller's avatar
Leigh B Stoller committed
432 433 434 435
	# Existing user, use existing auth token.
	# New user, we create a new one.
	$token = ($exists ? $exists->auth_token() : true);

Leigh B Stoller's avatar
Leigh B Stoller committed
436
	SPITFORM($username, $email, $sshkey, $profile, $token, $errors);
Leigh B Stoller's avatar
Leigh B Stoller committed
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468
	SPITFOOTER();
	return;
    }
}

# This is so we can look up the slice after the backend creates it.
$args["name"] = substr(GENHASH(), 0, 16);

#
# Generate a temporary file and write in the XML goo. 
#
$xmlname = tempnam("/tmp", "quickvm");
if (! $xmlname) {
    TBERROR("Could not create temporary filename", 0);
    $errors["internal"] = "Transient error(1); please try again later.";
}
elseif (! ($fp = fopen($xmlname, "w"))) {
    TBERROR("Could not open temp file $xmlname", 0);
    $errors["internal"] = "Transient error(2); please try again later.";
}
else {
    fwrite($fp, "<quickvm>\n");
    foreach ($args as $name => $value) {
	fwrite($fp, "<attribute name=\"$name\">");
	fwrite($fp, "  <value>" . htmlspecialchars($value) . "</value>");
	fwrite($fp, "</attribute>\n");
    }
    fwrite($fp, "</quickvm>\n");
    fclose($fp);
    chmod($xmlname, 0666);
}
if (count($errors)) {
Leigh B Stoller's avatar
Leigh B Stoller committed
469
    SPITFORM($username, $email, $sshkey, $profile, false, $errors);
Leigh B Stoller's avatar
Leigh B Stoller committed
470 471 472 473 474 475 476 477 478 479 480 481 482
    SPITFOOTER();
    return;
}

#
# Invoke the backend. This will create the user and the slice record
# in the SA database, and then fork off in the background. If the
# first part works, we can return to the user and use some nifty ajax
# and javascript to watch for progress. We use a cookie that holds
# the slice uuid so that the JS code can ask about it.
#
#
$retval = SUEXEC("nobody", "nobody", "webquickvm $xmlname",
Leigh B Stoller's avatar
Leigh B Stoller committed
483
		 SUEXEC_ACTION_CONTINUE);
Leigh B Stoller's avatar
Leigh B Stoller committed
484 485 486 487 488 489 490 491 492 493 494 495 496 497

if ($retval != 0) {
    if ($retval < 0) {
	$errors["internal"] = "Transient error(3); please try again later.";
    }
    else {
	if (count($suexec_output_array)) {
	    $line = $suexec_output_array[$i];
	    $errors["internal"] = $line;
	}
	else {
	    $errors["internal"] = "Transient error(4); please try again later.";
	}
    }
Leigh B Stoller's avatar
Leigh B Stoller committed
498
    SPITFORM($username, $email, $sshkey, $profile, false, $errors);
Leigh B Stoller's avatar
Leigh B Stoller committed
499 500 501 502 503 504 505 506
    SPITFOOTER();
    return;
}
unlink($xmlname);

$quickvm = QuickVM::LookupByName($args["name"]);
if (!$quickvm) {
    $errors["internal"] = "Transient error(5); please try again later.";
Leigh B Stoller's avatar
Leigh B Stoller committed
507
    SPITFORM($username, $email, $sshkey, $profile, false, $errors);
Leigh B Stoller's avatar
Leigh B Stoller committed
508 509 510 511 512 513
    SPITFOOTER();
    return;
}
$creator = GeniUser::Lookup("sa", $quickvm->creator_uuid());
if (! $creator) {
    $errors["internal"] = "Transient error(6); please try again later.";
Leigh B Stoller's avatar
Leigh B Stoller committed
514
    SPITFORM($username, $email, $sshkey, $profile, false, $errors);
Leigh B Stoller's avatar
Leigh B Stoller committed
515 516 517
    SPITFOOTER();
    return;
}
518
#
Leigh B Stoller's avatar
Leigh B Stoller committed
519
# Remember the user and auth key so that we can verify.
520 521 522 523 524 525 526 527 528 529 530 531 532
#
# The cookie handling is a pain since we run this under the aptlab
# virtual host, but the config uses a different domain, and so the
# cookies do not work. So, we have to look at our SERVER_NAME and
# set the cookie appropriately. 
#
if (stristr($_SERVER["SERVER_NAME"], $TBAUTHDOMAIN)) {
    $cookiedomain = $TBAUTHDOMAIN;
}
else {
    $cookiedomain = $_SERVER["SERVER_NAME"];
}
    
Leigh B Stoller's avatar
Leigh B Stoller committed
533
setcookie("quickvm_user",
534 535
	  $creator->uuid(), time() + (24 * 3600 * 30),
	  "/", $cookiedomain, 0);
Leigh B Stoller's avatar
Leigh B Stoller committed
536
setcookie("quickvm_authkey",
537 538
	  $creator->auth_token(), time() + (24 * 3600 * 30),
	  "/", $cookiedomain, 0);
Leigh B Stoller's avatar
Leigh B Stoller committed
539 540 541

header("Location: quickvm_status.php?uuid=" . $quickvm->uuid());
?>