<?php 
/*
    CREATIVE COMMONS - Attribution-No Derivative Works 3.0 Germany:
    - You may not alter, transform, or build upon this work.
    - Dieses Werk darf nicht bearbeitet oder in anderer Weise verändert werden.
*/
  echo '<p class="Headline">'.$L_Import.'</p>';
  if (!loggedIn())
    echo $L_003;
  else {
    if (!IsUserAdmin())
      echo $L_015;
    else {
      // Inhalt-Anfang
      foreach ($_POST as $key => $value) {
        $$key = trim($value); // ' -1\2'3"4<b>5&6; ' => '-1\2'3"4<b>5&6;'
        $$key = html_entity_decode($$key); // '&lt;b&gt;dog&lt;/b&gt;' => <b>dog</b>
        $$key = htmlspecialchars_decode($$key); // 'this -&gt; &quot;' => 'this -> "'
        $$key = stripslashes($$key); // O\'reilly? => O'reilly
        $$key = strip_tags($$key); // 'Hi <b>there</b>' => 'Hi there'
        $$key = htmlentities($$key); } // for displaying in the form+
      if (isset($Submit)) {
        if (isset($ImportGigs)
          OR isset($ImportGuestbook)
          OR isset($ImportNews)
          OR isset($ImportSetup)
          OR isset($ImportUser)) {
            include("functions/import.php"); }
        else {
          echo "<span class='ErrorMessage'>ERROR: Nothing selected!</span>"; }}
      else {
        // Prevent 'undefined index' notices
          $ImportGigs = 0;
          $ImportGuestbook = 0;
          $ImportNews = 0;
          $ImportSetup = 0;
          $ImportUser = 0;
          $ImportOverwriteGigs = 0;
          $ImportOverwriteGuestbook = 0;
          $ImportOverwriteNews = 0;
          $ImportOverwriteSetup = 1;
          $ImportOverwriteUser = 0;
          $Version = "12";
        echo $L_205.'<br /><br />';
        $directory = 'import';
        $handle = opendir($directory);
        $files = array();
        while ($file = readdir($handle))
          if ($file != "." && $file != "..")
            $files[] = $file;
        sort($files);
        $NumberOfFiles = count($files);
        if ($NumberOfFiles == 0)
          echo '<span class="ErrorMessage">'.$L_036.'<br />( '.PATH.'import/ )</span>';
        else {
          echo '<form method="post" action="index.php?submenue=admin&amp;content=import" accept-charset="UTF-8">
                  <table summary="Version">
                    <tr>
                      <td>v1.2</td>
                      <td><input type="radio" class="checkbox" name="Version" value="12" ';
                        if ($Version=="12") echo 'checked="checked"'; echo' /></td>
                    </tr>
                    <tr>
                      <td>v1.1</td>
                      <td><input type="radio" class="checkbox" name="Version" value="11" ';
                        if ($Version=="11") echo 'checked="checked"'; echo' /></td>
                    </tr>
                    <tr>
                      <td>v08.02.25</td>
                      <td><input type="radio" class="checkbox" name="Version" value="080225" ';
                        if ($Version=="080225") echo 'checked="checked"'; echo' /></td>
                    </tr>
                  </table>
                  <br />
                  <table summary="Import">
                    <tr>
                      <th>'.$NumberOfFiles.' '.$L_034.'</th>
                      <th>'.$L_035.'</th>
                      <th>'.$L_Import.'</th>
                      <th class="TabellenSpalte_Rechts">'.$L_Overwrite.'</th>
                    </tr>';
            $handle=opendir ($directory);
            while ($file = readdir($handle)) {
              if ($file != "." && $file != "..") {
	              $filesize =filesize('import/'.$file);
                $filesize = formatFileSize ($filesize, 2);
                $ElementName = ucfirst(str_replace('.csv', '', $file));
	              echo '<tr>
                        <td><a href="import/'.$file.'">'.$file.'</a></td>
                        <td style="text-align:right;">'.$filesize.'</td>';
                        if ( $ElementName=='Gigs' OR $ElementName=='Guestbook' OR $ElementName=='News'
                          OR $ElementName=='Setup' OR $ElementName=='User') {
                            echo '<td><input class="checkbox" type="checkbox" name="Import'.$ElementName.'" value="1" ';
                            if (${"Import".$ElementName}==1)
                              echo 'checked="checked" ';
                            echo '/></td>';
                            echo '<td><input class="checkbox" type="checkbox" name="ImportOverwrite'.$ElementName.'" value="1" ';
                            if (${"ImportOverwrite".$ElementName}==1)
                              echo 'checked="checked" ';
                            if ($ElementName=='Setup') echo 'disabled="disabled" checked="checked"';
                            echo' /></td>'; }
                        else {
                          echo '<td> </td>';
                          echo '<td> </td>'; }
                        echo '</tr>';
  	          }
            }
            echo '</table>';
            closedir($handle);
            echo '<br /><br />'.$L_148.'<br /><br />';
            echo '<fieldset>
                    <input name="Submit" type="submit" value="'.$L_Button23.'" class="button" />
                    <!-- <input name="Submit" type="submit" value="'.$L_Button24.'" class="button" />-->
                  </fieldset>
    	         </form>';
          }
        }
      // Inhalt zuende
    }
  }
?>