Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

import.php

Go to the documentation of this file.
00001 <?php
00011 /***************************************************************************
00012  This program is free software; you can redistribute it and/or
00013  modify it under the terms of the GNU General Public License
00014  as published by the Free Software Foundation; either version 2
00015  of the License, or (at your option) any later version.
00016 
00017  This program is distributed in the hope that it will be useful,
00018  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  GNU General Public License for more details.
00021 
00022  You should have received a copy of the GNU General Public License
00023  along with this program; if not, write to the Free Software
00024  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00025  ***************************************************************************/
00026 
00027 require_once ( './general.php' );
00028 
00029 // get styles
00030 $oStyle->setTemplate ( 'import.html' );
00031 $oStyle->split_area ( 'Eingabe' );
00032 
00033 // get variables
00034 if(isset($_POST['action']))     $action = $_POST['action'];
00035 elseif(isset($_GET['action']))  $action = $_GET['action'];
00036 else $action = 'list';
00037 
00038 if(isset($_POST['type']))      $strType = $_POST['type'];
00039 elseif(isset($_GET['type']))   $strType = $_GET['type'];
00040 else $strType = '';
00041 
00042 if(isset($_POST['show_import']))      $booShowImport = (bool) intval ( $_POST['show_import'] );
00043 elseif(isset($_GET['show_import']))   $booShowImport = (bool) intval ( $_GET['show_import'] );
00044 else $booShowImport = false;
00045 
00046 if(isset($_POST['source']))   $strData = trim( $_POST['source'] );
00047 else $strData = '';
00048 
00049 // import
00050 if ( $action == 'import' )
00051 {
00052     if ( ( $strType == 'html' ) || ( $strType == 'file' ) && $oUser->isAdmin ( 'import_map' ))
00053     {
00054         $strChecked = 'type=html';
00055         if ( $strType == 'file' )
00056         {
00057             $strChecked = 'type=file';
00058             $strData = implode ( '', file ( $_FILES['userfile']['tmp_name'] ) );
00059         }
00060         // create the objects
00061         require_once ( './lib/importbase.php' );
00062         require_once ( './lib/importhtml.php' );
00063         require_once ( './lib/towninfo.php' );
00064         $oTown = new TownInfo( $oMysql, $oLog );
00065         $oImport = new ImportHtml( $oMysql, $oUser, $oTown, $oLog );
00066         $aInfo = $oImport->import( $strData );
00067     }
00068     elseif ( $strType == 'guild' && $oUser->isAdmin ( 'import_guild' ) )
00069     {
00070         $strChecked = 'type=guild';
00071         // create the objects
00072         require_once ( './lib/importbase.php' );
00073         require_once ( './lib/importguild.php' );
00074         require_once ( './lib/towninfo.php' );
00075         $oTown = new TownInfo( $oMysql, $oLog );
00076         $oImport = new ImportGuild ( $oMysql, $oUser, $oTown, $oLog );
00077         $aInfo = $oImport->import ( $strData );
00078     }
00079     elseif ( $strType == 'scan' && $oUser->isAdmin ( 'import_town' ) )
00080     {
00081         $strChecked = 'type=scan';
00082         // create the objects
00083         require_once ( './lib/importbase.php' );
00084         require_once ( './lib/importscan.php' );
00085         require_once ( './lib/towninfo.php' );
00086         $oTown = new TownInfo( $oMysql, $oLog );
00087         $oImport = new ImportScan ( $oMysql, $oUser, $oTown, $oLog );
00088         $aInfo = $oImport->import ( $strData );
00089         if ( $aInfo === false )
00090         {
00091             $aInfo = array ( 0 => 'import.php', 1 => 'Kein Zugriff auf dieses Feld' );
00092         }
00093     }
00094     else
00095     {
00096         $aInfo = array ( 0 => 'import.php', 1 => 'Importart konnte nicht festegestellt werden. Das geschieht meistens, wenn man bei einem Gildenimport [GILDE=tag] in der ersten Zeile vergisst.' );
00097     }
00098     $strRefreshUrl = ( $booShowImport ) ? 'import.php?show_import=1&amp;'.$strChecked : $aInfo[0];
00099 
00100     $oStyle->addReplacements ( array ( 'TEMPLATES' => $oStyle->getPath(),
00101                                        'REFRESH_URL' => $strRefreshUrl,
00102                                        'REFRESH_MSG' => $aInfo[1] ) );
00103     echo $oStyle->get_area('Refresh');
00104     die();
00105 }
00106 // no import, show input fields
00107 else
00108 {
00109     $strShowImport = ($booShowImport)   ? ' checked="checked"' : '';
00110     $strHtml  = ( $strType == 'html' )  ? ' checked="checked"' : '';
00111     $strScan  = ( $strType == 'scan' )  ? ' checked="checked"' : '';
00112     $strFile  = ( $strType == 'file' )  ? ' checked="checked"' : '';
00113     $strGuild = ( $strType == 'guild' ) ? ' checked="checked"' : '';
00114 
00115     $oStyle->addReplacements ( array ( 'SHOW_IMPORT' => $strShowImport,
00116                                        'HTML_CHECKED' => $strHtml,
00117                                        'SCAN_CHECKED' => $strScan,
00118                                        'GUILD_CHECKED' => $strGuild,
00119                                        'FILE_CHECKED' => $strFile ) );
00120     $strTmpl_inhalt = $oStyle->get_area ( 'Eingabe' );
00121     output();
00122 }

Generated on Sun May 8 19:29:45 2005 for PhpMap by  doxygen 1.4.2