<?
/*
//||||||||||||||||||||||||||||||||||||||||||||||||\\
\\*          SUPER HERO MOD WEB STATS 3.0         //
//                                                \\
\\  Written By ShadowLeader aka 123 (Tim Hansen)  //
//                                                \\
\\              http://SH-MOD.TK                  //
//          Email: shadowleader@jubii.dk          \\
\\          MSN: shadowleader11@hotmail.com       //
//                                                \\
\\   You are allowed to edit anything in these    //
//     files, as long as these lines remain.      \\
\\                                                //
//   If you have any trouble with the system,     \\
\\       go to www.SH-MOD.TK to get help.         //
//                                                \\
\\   Thanks to:                                   //
//   AlleyKat - Help with Template system         \\
\\   MajesticM00se - A little code                //
//   Vittu - Finding bugs                         \\
\\||||||||||||||||||||||||||||||||||||||||||||||||//
*/

require "include/header.php";

dbconn(true);

stdhead();
/////////START/////////
?>
<table border="1" cellspacing="0" style="border-collapse: collapse; border-right: 1px solid; border-left: 1px solid; border-top: 0px; border-bottom: 0px" width="100%" cellpadding="2">
<tr>
<td valign="top" style="border-top: 1px solid; border-bottom: 1px solid">
<?php
if($thestring OR $CURUSER['class'] >= UC_ADMINISTRATOR){
if($_POST['Submit']){
mysql_query("UPDATE sh_config SET maxxp = '$_POST[maxxp]' where id = '1'") or die(mysql_error());
mysql_query("UPDATE sh_config SET levels = '$_POST[levels]' where id = '1'") or die(mysql_error());
mysql_query("UPDATE sh_config SET allow_dl = '$_POST[allow_dl]' where id = '1'") or die(mysql_error());
mysql_query("UPDATE sh_config SET servername = '$_POST[servername]' where id = '1'") or die(mysql_error());
mysql_query("UPDATE sh_config SET serverip = '$_POST[serverip]' where id = '1'") or die(mysql_error());
mysql_query("UPDATE sh_config SET max = '$_POST[max]' where id = '1'") or die(mysql_error());
mysql_query("UPDATE sh_config SET template = '$_POST[template]' where id = '1'") or die(mysql_error());
mysql_query("UPDATE sh_config SET root_path = '$_POST[root_path]' where id = '1'") or die(mysql_error());
//echo"$_POST[maxxp], $_POST[levels], $_POST[allow_dl], $_POST[servername], $_POST[serverip], $_POST[max], $_POST[template]";
echo"Updated";
header("Location: $BASEURL/admin_config.php?updated=1");
}
if(!$_POST['Submit']){
$result = mysql_query("SELECT * FROM sh_config WHERE id = '1'") or die(mysql_error());
while($row = mysql_fetch_array($result)) {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<table width=100%>
<tr>
  <td colspan="3">
<?
if($_GET["updated"] == "1"){
echo"Updated";
}
?>
  </td>
</tr>
<tr>
 <td width=15%>Max xp: </td>
 <td width=20%><input name="maxxp" class="input" type="text" id="maxxp" value="<? echo"$row[maxxp]";?>" size="20" maxlength="20">&nbsp;</td>
 <td width=65%>&nbsp;// Set the max amount of xp on your server</td>
</tr>
<tr>
 <td width=15%>Levels:</td>
 <td width=20%><input name="levels" class="input" type="text" id="levels" value="<? echo"$row[levels]";?>" size="20" maxlength="3">&nbsp;</td>
 <td width=65%>&nbsp;// Set the amount of levels you have on your server</td>
</tr>
<tr>
  <td width=15%>Allow Download: </td>
  <td><select name="allow_dl" class="input" id="allow_dl">
<? if ($row[allow_dl] == "1"){
   echo"<option value=\"1\" selected>Yes</option>
   <option value=\"0\">No</option>"; 
   }if ($row[allow_dl] == "0"){
   echo"<option value=\"1\">Yes</option>
   <option value=\"0\" selected>No</option>"; 
   }
?>
  </select>&nbsp;</td>
  <td>&nbsp;// Allow users to download the heroes</td>
</tr>
<tr>
  <td width=15%>Server Name: </td>
  <td><input name="servername" class="input" type="text" id="servername" value="<? echo"$row[servername]";?>" size="20" maxlength="30">&nbsp;</td>
  <td>&nbsp;// Set the server name</td>
</tr>
<tr>
  <td width=15%>Server IP: </td>
  <td><input name="serverip" class="input" type="text" id="serverip" value="<? echo"$row[serverip]";?>" size="20" maxlength="21">&nbsp;</td>
  <td>&nbsp;// Set server IP</td>
</tr>
<tr>
  <td width=15%>Root Path: </td>
  <td><input name="root_path" class="input" type="text" id="root_path" value="<? echo"$row[root_path]";?>" size="20" maxlength="21">&nbsp;</td>
  <td>&nbsp;// Set Root path (Default: stats)</td>
</tr>
<tr>
  <td width=15%>Players pr. page: </td>
  <td><input name="max" class="input" type="text" id="max" value="<? echo"$row[max]";?>" size="20" maxlength="3">&nbsp;</td>
  <td>&nbsp;// How many players to show per page</td>
</tr>
<tr>
  <td width=15%>Template:</td>
  <td>
<? 
$scandir = "./templates/"; // Where are the templates located ?
$dirliste = array();

// First we have to get the content of the dir.
$count = 0;
// Check dir
if ($handle = opendir($scandir)) {
   while (false !== ($file = readdir($handle))) {
       if ($file != "." && $file != "..") {
          if (is_dir($scandir.$file)) {
             $dirliste[$count] = $file;
             $count++;
          }
       }
   }
   closedir($handle);
}

$dirtaeller = $count ;
$count = 0 ;
// Check wether the css file is located in the correct folder.
$template_list = '<select class="input" name="template">';
while ( $dirtaeller > $count ) {
      if( (is_file($scandir.$dirliste[$count]."/sh_".$dirliste[$count].".css")) ) {
      // Make the select box
	  
for( $i = 0; $i < count($dirliste[$count]); $i++ ) {
   if ($dirliste[$count] == $row[template]){
      $template_list .= '<option selected value="'.$dirliste[$count].'">'.$dirliste[$count].'</option>';
	  
   }else{
      $template_list .= '<option  value="'.$dirliste[$count].'">'.$dirliste[$count].'</option>';
	  
}    }
      } else {
         echo "No CSS-files here!";
      }
            $count++;
}$template_list .= '</select>';
 echo $template_list;?>
  &nbsp;</td>
  <td>&nbsp;// What template to use (Default: Blue, Red, Green) [<a href="http://forum2.pandersenfisk.dk/viewforum.php?f=16">More</a>]</td>
</tr>
<tr>
  <td colspan="3"><input type="submit" class="input" name="Submit" value="Submit"></td>
  <tr>
  <td></td>
  <td colspan="2"></td>
</tr>
</table>
</form>
<? }}
}else{echo"You do not have access to this page."; }?><br>
</td>
</tr>
</table>
<?
/////////END/////////
stdfoot();
?>