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

tools.php

Go to the documentation of this file.
00001 <?php
00009 /***************************************************************************
00010  This program is free software; you can redistribute it and/or
00011  modify it under the terms of the GNU General Public License
00012  as published by the Free Software Foundation; either version 2
00013  of the License, or (at your option) any later version.
00014 
00015  This program is distributed in the hope that it will be useful,
00016  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  GNU General Public License for more details.
00019 
00020  You should have received a copy of the GNU General Public License
00021  along with this program; if not, write to the Free Software
00022  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00023  ***************************************************************************/
00024 
00025 require_once( './general.php' );
00026 require_once( './lib/tools.php' );
00027 
00028 // get styles
00029 $oStyle->setTemplate( 'tools.html' );
00030 $oStyle->split_area( 'ToolsList' );
00031 $oStyle->split_area( 'CleanSure' );
00032 
00033 $oTools = new Tools( $oMysql );
00034 
00035 // get variables
00036 if(isset($_POST['action']))     $action = $_POST['action'];
00037 elseif(isset($_GET['action']))  $action = $_GET['action'];
00038 else $action = '';
00039 
00040 if( $action == 'import' && $oUser->isAdmin( 'csv_import' ) )
00041 {
00042     $intLine = isset( $_GET['line'] ) ? intval( $_GET['line'] ) : 1;
00043 
00044     if( !isset( $_GET['dbclean'] ) )
00045     {
00046         $aRows = $oMysql->query_first( "SELECT COUNT(x) FROM ".$oMysql->tblMap.";" );
00047         $booDbIsClean = !( $aRows[0] > 0 );
00048     }
00049     else
00050     {
00051         $booDbIsClean = (bool) $_GET['dbclean'];
00052     }
00053 
00054     $intReturn = $oTools->csvimport( $intServerId, $intLine, 10, $booDbIsClean );
00055 
00056     if( $intReturn === true )
00057     {
00058         $oStyle->addReplacements( array( 'REFRESH_MSG' => 'Kartenimport beendet f&uuml;r Server '.$intServerId,
00059                                          'REFRESH_URL' => 'map.php' ) );
00060     }
00061     elseif( $intReturn === false )
00062     {
00063         $oStyle->addReplacements( array( 'REFRESH_MSG' => 'Die server'.$intServerId.'.csv wurde nicht gefunden.<br />'.
00064                                                           'Diese muss sich im Hauptordner befinden.<br />'.
00065                                                           'Die jeweils aktuelle findet man im <a href="http://forum.andaloria.de/viewtopic.php?t=12570" target="_blank">Forum</a>.',
00066                                          'REFRESH_URL' => 'admin.php' ) );
00067     }
00068     else
00069     {
00070         $dblPercent = $intReturn / $intMapSize;
00071         $oStyle->addReplacements( array( 'BAR_WIDTH' => 400, 
00072                                          'BAR_WIDTH2' => round( 400 * $dblPercent),
00073                                          'BAR_WIDTH3' => round( 400 - 400 * $dblPercent),
00074                                          'BAR_HEIGHT' => 15 ) );
00075         $strBar = $oStyle->get_area( 'Bar' );
00076         $oStyle->addReplacements( array( 'REFRESH_MSG' => '<br />'.$strBar.'Kartenimport f&uuml;r Server '.$intServerId. ' l&auml;uft. ('.round( $dblPercent * 100).'%)',
00077                                          'REFRESH_URL' => 'tools.php?action=import&amp;line='.$intReturn.'&amp;dbclean='.intval( $booDbIsClean ) ) );
00078     }
00079     echo $oStyle->get_area( 'Refresh' );
00080     die();
00081 }
00082 elseif( $action == 'clean' && $oUser->isAdmin( 'db_clean' ) )
00083 {
00084     if( !isset( $_GET['delmap'] ) || !(bool)$_GET['delmap'] )
00085     {
00086         $strTmpl_inhalt = $oStyle->get_area( 'CleanSure' );
00087     }
00088     else
00089     {
00090         $intReturn = $oTools->clean( (bool)$_GET['delmap'] );
00091         $oStyle->addReplacements( array( 'REFRESH_MSG' => 'Daten gel&ouml;scht. ('.$intReturn.' Eintr&auml;ge)',
00092                                          'REFRESH_URL' => 'admin.php' ) );
00093         echo $oStyle->get_area( 'Refresh' );
00094         die();
00095     }
00096 }
00097 else
00098 {
00099     $strRows = ( $strServerStats != '' ) ? $oStyle->get_area( 'ToolsStats' ) : '';
00100     $strRows .= ( $oUser->isAdmin( 'fight' ) ) ? $oStyle->get_area( 'ToolsFight' ) : '';
00101     $oStyle->addReplacements( array( 'ROWS' => $strRows ) );
00102 
00103     $strTmpl_inhalt = $oStyle->get_area( 'ToolsList' );
00104 }
00105 output();

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