<?php
/*Realism Clan Manager - Best for extra management of Realism Gaming Clans/Community.
    Copyright (C) 2013  Michael Woods aka Blood_Wolf89

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, version 3 of the License.

    This program 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 General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see http://www.gnu.org/licenses/ */
ini_set('error_reporting', 'E_ALL ^ E_NOTICE');
include_once '../include/processes.php';
$Login_Process = new Login_Process;
$Login_Process->check_status($_SERVER['SCRIPT_NAME']);


INCLUDE 'setup.php' ; 
INCLUDE ($langinclude) ;
function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $path_parts = pathinfo($_SERVER["REQUEST_URI"]);
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$path_parts['dirname'];
 } else {
  $path_parts = pathinfo($_SERVER["REQUEST_URI"]);
  $pageURL .= $_SERVER["SERVER_NAME"].$path_parts['dirname'];
 }
 return $pageURL;
}

$xml = simplexml_load_file("$path_dir");
//print_r ($xml);
$rowColor = "ab";
$myUrl = curPageURL().'/xmlf/squad.xml';
?>
<html>
<head>
<title>SquadXML-Editor</title>
<link rel="stylesheet" type="text/css" href="squadxml.css">
<link rel="stylesheet" type="text/css" href="../css/style.css">
</head>
<body>
<?php include('header.php')?>
<div id="main">
  <div class="container"><center>
<h1>RCM XML Editor</h1>

<h2><?php echo $lng_modeOverview; ?></h2>
<p>squad.xml URL: <a href="<?php echo $myUrl; ?>"><?php echo $myUrl; ?></a></p>
<?php
$indexOfChildOne = 0;
echo '<table width="750" cellpadding="0" cellspacing="0" >';

foreach($xml as $key0 => $value){
	if ($rowColor == "ab") {$rowColor = "ba";} else {$rowColor = "ab";}
	if ($indexOfChildOne < 1) {
		foreach($xml->attributes() as $attributeskey0 => $attributesvalue1){
			echo '<tr class="'.$rowColor.'"><td class="keytext">'.$attributeskey0.': </td><td colspan="2">'.utf8_decode($attributesvalue1).'</td>';
			echo '<td>';
			echo '<a href="./squadxml_edit.php?key=xxx&value='.$indexOfChildOne.'"><img src="./gfx/application_edit.png" alt="'.$lng_change.'"></a>';
			echo '</td>';
			echo '<td></td>';
			$rowColor = "ab";
		}
	}
	echo '<tr class="'.$rowColor.'"><td class="keytext">'.$key0.': </td>';
	if ($indexOfChildOne < 5) {echo '<td colspan="2">'.utf8_decode($value).'</td>';}
	
	foreach($value->attributes() as $attributeskey0 => $attributesvalue1){
		echo '<td>';
		echo '<span  class="keytext">'.$attributeskey0.'</span>: <b>'.utf8_decode($attributesvalue1).'</b>';
		echo '</td>';
	}
	echo '<td>';
	echo '<a href="./squadxml_edit.php?key='.$key0.'&value='.$indexOfChildOne.'"><img src="./gfx/application_edit.png" alt="'.$lng_change.'"></a>';
	echo '</td>';
	if ($indexOfChildOne > 4) {
		echo '<td>';
		echo '<a href="./squadxml_del.php?value='.$indexOfChildOne.'" onclick="return confirm(\''.$lng_deleteMessage.'\');"><img src="./gfx/cross.png" alt="'.$lng_delete.'"></a>';
		echo '</td>';
	} else {echo '<td></td>';}
	echo "</tr>\r\n";
	$indexOfChildOne++;
	////////////////////////////////////////////////
	if ($indexOfChildOne > 5) {
	echo '<tr class="'.$rowColor.'"><td></td><td colspan="4">';
	foreach($value as $key => $value2){
		echo '<span  class="keytext">'.$key.'</span>: '.utf8_decode($value2).'<span  class="keytext"> , </span>';
		foreach($value2->attributes() as $attributeskey => $attributesvalue2){
			echo '<td>'.$attributeskey.': '.utf8_decode($attributesvalue2).'</td>';
		}
	}
	echo "</td></tr>\r\n";
	}
echo '<tr><td colspan="5" class="hrpart"></td></tr>';	
}

echo '</table>';
$indexOfChildOne + 1;
echo '<br/><a href="./squadxml_edit.php?key='.$key0.'&value='.$indexOfChildOne.'"><img src="./gfx/add.png" alt="'.$lng_add.'"> '.$lng_add.' New Player</a>';
?>
</center>
</div>
</div>


<?php include('../include/footer.php');?>


</body>
</html>