<?php

require_once('include/admin.inc.php');

auth_redirect(); // Require logged in user to access this page.

if($_POST)
{
	check_nonce('swap-strip');

	if(!is_numeric($_POST['comic_a']) || !is_numeric($_POST['comic_b']))
		mtdie('This tool only works on numeric strip numbers.');

	$a = (int)$_POST['comic_a'];
	$b = (int)$_POST['comic_b'];

	$f = fopen(SITE_PATH_ABS.'/'.SITE_STRIP.'/'.SITE_STRIP_LOCK, 'w');
	flock($f, LOCK_EX);

	swap_strips( $a, $b );

	close($f);

	$info.='<p>Strips $a and $b swapped successfully.</p>';
	adminlog("Strips $a and $b have been swapped.", MTS_STRIP, MTA_MODIFY);
}



adminhead('Swap Comics');
adminmenu('swap-comics.php');

?>

<h2>Swap Comics</h2>

<form action="swap-comics.php" method="post" name="post" id="post">

<div id="poststuff">

	<table class="editform" width="100%" cellspacing="2" cellpadding="5">
	<tr>
	<th scope="row" width="33%">First Comic</th>
	<td width="66%"><input name="comic_a" type="text" id="comic_a" value="" /></th>
	</tr>
	<tr>
	<th scope="row" width="33%">Second Comic</th>
	<td width="66%"><input name="comic_b" type="text" id="comic_b" value="" /></th>
	</tr>
	</table>

	<p class="submit"><input type="submit" value="Swap &raquo;" name="submit" /></p>

</div>

</form>

<?php adminfooter() ?>
