<commit_before><?php // -*- mode: php -*-

if (file_exists('../root.php'))
  include_once('../root.php');
$admin = true;
$textures = false;
include_once(root.'inc/fp.php');

define('MAX_X_NON_DONJON', 190);
define('MAX_Y_NON_DONJON', 190);

if (array_key_exists('change', $_GET)) {
	$first = true;
	$req = "insert into map (x, y, type, decor, info) values \n";
	foreach ($_POST['changes'] as $c) {
		if ($first) $first = false;
		else $req .= ",\n";
		$x = acase::get_x($c['case']);
		$y = acase::get_y($c['case']);
		if (array_key_exists('type', $c)) {
			$type = $c['type'];
		} else {
			$type = 0;
			if ($x > MAX_X_NON_DONJON || $y > MAX_Y_NON_DONJON)
				$type = 2;
		}
		$decor = $c['decor'];
		$info = floor($decor / 100);
		$req .= "($x, $y, $type, $decor, $info)";
	}
	$req .= "\nON DUPLICATE KEY UPDATE type = VALUES(type), decor = VALUES(decor), info = VALUES(info)";
	$res = $db->query($req);
	if ($_POST['showQ'] == 'true')
		$_SESSION['last_query'] = "$req\n".print_r($db->get_mysql_info(), true);
	else
		$_SESSION['last_query'] = null;
	echo '<script type="text/javascript">location.reload();</script>';
	exit(0);
}
if (array_key_exists('modevent', $_REQUEST) && $_REQUEST['modevent']) {
	if ($_REQUEST['titre'] == '') {
		$db->query("DELETE FROM map_event WHERE x = $_REQUEST[x] AND y = $_REQUEST[y]");
	}
	else {
		$titre = mysql_escape_string(stripslashes($_REQUEST['titre']));
		$description = mysql_escape_string(stripslashes($_REQUEST['descr']));
		$q = "INSERT INTO map_event (x, y, `titre`, `description`, `action`, `code`, `sql`) ";
		$qq = "VALUES ($_REQUEST[x], $_REQUEST[y], '$titre', '$description', ";
		if ($_REQUEST['action'] != '')
			$qq .= '\''.mysql_escape_string(stripslashes($_REQUEST['action'])).'\', ';
		else
			$qq .= 'NULL, ';
		if ($_REQUEST['code'] != '')
			$qq .= '\''.mysql_escape_string(stripslashes($_REQUEST['code'])).'\', ';
		else
			$qq .= 'NULL, ';
		if ($_REQUEST['sql'] != '')
			$qq .= '\''.mysql_escape_string(stripslashes($_REQUEST['sql'])).'\'';
		else
			$qq .= 'NULL';
		$qqq = ') ON DUPLICATE KEY UPDATE `titre` = VALUES(`titre`), `description` = VALUES(`description`), `action` = VALUES(`action`), `code` = VALUES(`code`), `sql` = VALUES(`sql`)';
		
		$res = $db->query($q.$qq.$qqq);
		echo 'Modification effectu&eacute;e.<br/>';
	}
}
if (array_key_exists('infoscase', $_REQUEST)) {
	$x = $_REQUEST['infoscase'] % 1000;
	$y = floor($_REQUEST['infoscase'] / 1000);
	$q = "select * from map left join map_event using (x, y) where x = $x and y = $y";
	$res = $db->query($q);
	$row = $db->read_assoc($req);
	echo "Case $x / $y : décor $row[decor], type : $row[type]";
	echo "<div style=\"width: 60px; height: 60px;\" class=\"decor tex$row[decor]\"></div>";
	echo '<hr><form method="post" action="#" id="eventform"><div>';
	echo '<h3>Event</h3>';
	if ($row['titre'] == '') { echo '<small>(pas d\'event)</small>'; }
	echo '<table>';
	echo '<tr><td>Titre: </td><td><input type="text" name="titre" value="'.
		$row['titre'].'"/></td></tr>';<commit_msg>ajout de l'info dans l'info case<commit_after><?php // -*- mode: php -*-

if (file_exists('../root.php'))
  include_once('../root.php');
$admin = true;
$textures = false;
include_once(root.'inc/fp.php');

define('MAX_X_NON_DONJON', 190);
define('MAX_Y_NON_DONJON', 190);

if (array_key_exists('change', $_GET)) {
	$first = true;
	$req = "insert into map (x, y, type, decor, info) values \n";
	foreach ($_POST['changes'] as $c) {
		if ($first) $first = false;
		else $req .= ",\n";
		$x = acase::get_x($c['case']);
		$y = acase::get_y($c['case']);
		if (array_key_exists('type', $c)) {
			$type = $c['type'];
		} else {
			$type = 0;
			if ($x > MAX_X_NON_DONJON || $y > MAX_Y_NON_DONJON)
				$type = 2;
		}
		$decor = $c['decor'];
		$info = floor($decor / 100);
		$req .= "($x, $y, $type, $decor, $info)";
	}
	$req .= "\nON DUPLICATE KEY UPDATE type = VALUES(type), decor = VALUES(decor), info = VALUES(info)";
	$res = $db->query($req);
	if ($_POST['showQ'] == 'true')
		$_SESSION['last_query'] = "$req\n".print_r($db->get_mysql_info(), true);
	else
		$_SESSION['last_query'] = null;
	echo '<script type="text/javascript">location.reload();</script>';
	exit(0);
}
if (array_key_exists('modevent', $_REQUEST) && $_REQUEST['modevent']) {
	if ($_REQUEST['titre'] == '') {
		$db->query("DELETE FROM map_event WHERE x = $_REQUEST[x] AND y = $_REQUEST[y]");
	}
	else {
		$titre = mysql_escape_string(stripslashes($_REQUEST['titre']));
		$description = mysql_escape_string(stripslashes($_REQUEST['descr']));
		$q = "INSERT INTO map_event (x, y, `titre`, `description`, `action`, `code`, `sql`) ";
		$qq = "VALUES ($_REQUEST[x], $_REQUEST[y], '$titre', '$description', ";
		if ($_REQUEST['action'] != '')
			$qq .= '\''.mysql_escape_string(stripslashes($_REQUEST['action'])).'\', ';
		else
			$qq .= 'NULL, ';
		if ($_REQUEST['code'] != '')
			$qq .= '\''.mysql_escape_string(stripslashes($_REQUEST['code'])).'\', ';
		else
			$qq .= 'NULL, ';
		if ($_REQUEST['sql'] != '')
			$qq .= '\''.mysql_escape_string(stripslashes($_REQUEST['sql'])).'\'';
		else
			$qq .= 'NULL';
		$qqq = ') ON DUPLICATE KEY UPDATE `titre` = VALUES(`titre`), `description` = VALUES(`description`), `action` = VALUES(`action`), `code` = VALUES(`code`), `sql` = VALUES(`sql`)';
		
		$res = $db->query($q.$qq.$qqq);
		echo 'Modification effectu&eacute;e.<br/>';
	}
}
if (array_key_exists('infoscase', $_REQUEST)) {
	$x = $_REQUEST['infoscase'] % 1000;
	$y = floor($_REQUEST['infoscase'] / 1000);
	$q = "select * from map left join map_event using (x, y) where x = $x and y = $y";
	$res = $db->query($q);
	$row = $db->read_assoc($req);
	echo "Case $x / $y : décor $row[decor] (info $row[info]), type : $row[type]";
	echo "<div style=\"width: 60px; height: 60px;\" class=\"decor tex$row[decor]\"></div>";
	echo '<hr><form method="post" action="#" id="eventform"><div>';
	echo '<h3>Event</h3>';
	if ($row['titre'] == '') { echo '<small>(pas d\'event)</small>'; }
	echo '<table>';
	echo '<tr><td>Titre: </td><td><input type="text" name="titre" value="'.
		$row['titre'].'"/></td></tr>';
{'fraction_non_alphanumeric': 0.26102030708271423, 'fraction_numerical': 0.00858510813934291, 'mean_word_length': 4.682926829268292, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4403892', 'n_tokens_mistral': 2530, 'n_tokens_neox': 2345, 'n_words': 490}