<?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.
*/
  $_SESSION['MenuReminderAdmin'] = $page;
  
  if ( !loggedIn() ) { echo $L_003; }
  else
  {
    if ( !IsUserAdmin() ) echo $L_015;
    else
    {
      // Inhalt-Anfang
        if (isset($Submit))
        {
          if ($Submit==$L_Button23)
        	{
            if (isset($_POST["ImportGigs"])) $_SESSION["ImportGigs"] = $_POST["ImportGigs"];
              else $_SESSION["ImportGigs"] = 0;
            if (isset($_POST["ImportGuestbook"])) $_SESSION["ImportGuestbook"] = $_POST["ImportGuestbook"];
              else $_SESSION["ImportGuestbook"] = 0;
            if (isset($_POST["ImportNews"])) $_SESSION["ImportNews"] = $_POST["ImportNews"];
              else $_SESSION["ImportNews"] = 0;
            if (isset($_POST["ImportSetup"])) $_SESSION["ImportSetup"] = $_POST["ImportSetup"];
              else $_SESSION["ImportSetup"] = 0;
            if (isset($_POST["ImportUser"])) $_SESSION["ImportUser"] = $_POST["ImportUser"];
              else $_SESSION["ImportUser"] = 0;
            if (isset($_POST["ImportOverwriteGigs"])) $_SESSION["ImportOverwriteGigs"] = $_POST["ImportOverwriteGigs"];
              else $_SESSION["ImportOverwriteGigs"] = 0;
            if (isset($_POST["ImportOverwriteGuestbook"])) $_SESSION["ImportOverwriteGuestbook"] = $_POST["ImportOverwriteGuestbook"];
              else $_SESSION["ImportOverwriteGuestbook"] = 0;
            if (isset($_POST["ImportOverwriteNews"])) $_SESSION["ImportOverwriteNews"] = $_POST["ImportOverwriteNews"];
              else $_SESSION["ImportOverwriteNews"] = 0;
            if (isset($_POST["ImportOverwriteSetup"])) $_SESSION["ImportOverwriteSetup"] = $_POST["ImportOverwriteSetup"];
              else $_SESSION["ImportOverwriteSetup"] = 0;
            if (isset($_POST["ImportOverwriteUser"])) $_SESSION["ImportOverwriteUser"] = $_POST["ImportOverwriteUser"];
              else $_SESSION["ImportOverwriteUser"] = 0;
            if (isset($_POST["Version"])) $_SESSION["Version"] = $_POST["Version"];
              else $_SESSION["Version"] = 0;
            include("functions/import.php");
        	}
        	if ($Submit==$L_Import) { echo $L_150.'<br />'; }
        }
    	  else
        {
          if (!isset($_SESSION["ImportGigs"])) $_SESSION["ImportGigs"] = 0;
          if (!isset($_SESSION["ImportGuestbook"])) $_SESSION["ImportGuestbook"] = 0;
          if (!isset($_SESSION["ImportNews"])) $_SESSION["ImportNews"] = 0;
          if (!isset($_SESSION["ImportSetup"])) $_SESSION["ImportSetup"] = 0;
          if (!isset($_SESSION["ImportUser"])) $_SESSION["ImportUser"] = 0;
          if (!isset($_SESSION["ImportOverwriteGigs"])) $_SESSION["ImportOverwriteGigs"] = 1;
          if (!isset($_SESSION["ImportOverwriteGuestbook"])) $_SESSION["ImportOverwriteGuestbook"] = 1;
          if (!isset($_SESSION["ImportOverwriteNews"])) $_SESSION["ImportOverwriteNews"] = 1;
          $_SESSION["ImportOverwriteSetup"] = 0;
          if (!isset($_SESSION["ImportOverwriteUser"])) $_SESSION["ImportOverwriteUser"] = 1;
          if (!isset($_SESSION["Version"])) $_SESSION["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 );
          $AnzahlDateien = count($files);
          if ($AnzahlDateien == 0)
          {
            echo '<span class="ErrorMessage">'.$L_036.'<br />( '.GIGKALENDERPATH.'import/ )</span>';
          }
          else
          { 
            echo '<form method="post" action="index.php?submenu=admin&amp;page=import" accept-charset="UTF-8">
                    <table summary="Version">
                      <tr>
                        <td>v1.2</td>
                        <td><input type="radio" class="checkbox" name="Version" value="12" '; if ($_SESSION["Version"]=="12") echo 'checked="checked"'; echo' /></td>
                      </tr>
                      <tr>
                        <td>v1.1</td>
                        <td><input type="radio" class="checkbox" name="Version" value="11" '; if ($_SESSION["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 ($_SESSION["Version"]=="080225") echo 'checked="checked"'; echo' /></td>
                      </tr>
                    </table>
                    <br />
                    <table summary="Import">
                      <tr>
                        <th>'.$AnzahlDateien.' '.$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 = ceil($filesize/1024).' KB';
                  if ($filesize >= 1024) {$filesize = round($filesize/1024,3).' MB';}
                  $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 ($_SESSION["Import".$ElementName]==1) echo 'checked="checked" ';
                            echo '/></td>';
                            echo '<td><input class="checkbox" type="checkbox" name="ImportOverwrite'.$ElementName.'" value="1" ';
                            if ($_SESSION["ImportOverwrite".$ElementName]==1) echo 'checked="checked" ';
                            if ($ElementName=='Setup') echo 'disabled="disabled"';
                            echo' /></td>';
                          }
                          else
                          {
                            echo '<td><input class="checkbox" type="checkbox" disabled="disabled" /></td>';
                            echo '<td><input class="checkbox" type="checkbox" disabled="disabled" /></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" />
                    </fieldset>
      	         </form>';
          }
        }
      // Inhalt zuende
    }
  }
?>