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

search.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************************
00003  This program is free software; you can redistribute it and/or
00004  modify it under the terms of the GNU General Public License
00005  as published by the Free Software Foundation; either version 2
00006  of the License, or (at your option) any later version.
00007 
00008  This program is distributed in the hope that it will be useful,
00009  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  GNU General Public License for more details.
00012 
00013  You should have received a copy of the GNU General Public License
00014  along with this program; if not, write to the Free Software
00015  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00016  ***************************************************************************/
00017 
00018 require_once ('./general.php');
00019 require_once ('./lib/search.php');
00020 
00021 if ( !$oUser->isAdmin ( 'search' ) )
00022 {
00023     die('Keine Admin Rechte.');
00024 }
00025 
00026 //Lese Html-Styles
00027 $oStyle->setTemplate ( 'search.html' );
00028 $oStyle->split_area('ResultRow');
00029 $oStyle->split_area('Result');
00030 $oStyle->split_area('NoResult');
00031 $oStyle->split_area('Input');
00032 
00033 // get variables
00034 
00035 if(isset($_POST['name']))      $strName = $_POST['name'];
00036 elseif(isset($_GET['name']))   $strName = $_GET['name'];
00037 else $strName = '';
00038 
00039 if(isset($_POST['guild']))     $strGuild = $_POST['guild'];
00040 elseif(isset($_GET['guild']))  $strGuild = $_GET['guild'];
00041 else $strGuild = '';
00042 
00043 if(isset($_POST['sy']))      $intY = intval($_POST['sy']);
00044 elseif(isset($_GET['sy']))   $intY = intval($_GET['sy']);
00045 else $intY = 0;
00046 
00047 if(isset($_POST['sx']))         $intX = intval($_POST['sx']);
00048 elseif(isset($_GET['sx']))      $intX = intval($_GET['sx']);
00049 else $intX = 0;
00050 
00051 if(isset($_POST['radius']))    $intRadius = intval($_POST['radius']);
00052 elseif(isset($_GET['radius'])) $intRadius = intval($_GET['radius']);
00053 else $intRadius = 0;
00054 
00055 if(isset($_POST['guildid']))    $intGuild = intval($_POST['guildid']);
00056 elseif(isset($_GET['guildid'])) $intGuild = intval($_GET['guildid']);
00057 else $intGuild = 0;
00058 
00059 if(isset($_POST['sortby']))    $strOrder = $_POST['sortby'];
00060 elseif(isset($_GET['sortby'])) $strOrder = $_GET['sortby'];
00061 else $strOrder = 'name';
00062 
00063 $booSubmit = isset ( $_POST['submit'] ) || isset ( $_GET['submit'] ) || $intGuild != 0;
00064 
00065 $oSearch = new Search ( $oMysql, $oUser );
00066 if ( $booSubmit )
00067 {
00068     $aResult = $oSearch->doSearch ( $strName, $strGuild, $intGuild, $intX, $intY, $intRadius, $strOrder );
00069 }
00070 
00071 $oStyle->addReplacements ( array ( 'URL_X' => ($intX>0) ? 'sx='.$intX.'&amp;' : '',
00072                                    'URL_Y' => ($intY>0) ? 'sy='.$intY.'&amp;' : '',
00073                                    'URL_GUILD_ID' => isset ( $intGuild ) ? 'guildid='.$intGuild.'&amp;' : '',
00074                                    'URL_RADIUS' => $intRadius,
00075                                    'URL_NAME' => urlencode($strName),
00076                                    'URL_GUILD' => urlencode($strGuild),
00077                                    'URL_ORDER' => urlencode($strOrder)
00078                                 )
00079                           );
00080 
00081 $strSearchResult = '';
00082 if ( $booSubmit )
00083 {
00084     $strSearchList = '';
00085     $i = 0;
00086     foreach ( $aResult AS $aData )
00087     {
00088         $oStyle->addReplacements ( array ( 'SEARCH_PLAYER' => $aData['name'],
00089                                            'SEARCH_TOWN' => $aData['townname'],
00090                                            'SEARCH_GUILD' => $aData['guild_tag']!='' ? '['.$aData['guild_tag'].']' : '',
00091                                            'SEARCH_GUILD_ID' => $aData['guild_id'],
00092                                            'SEARCH_MAP_X' => $aData['x'],
00093                                            'SEARCH_MAP_Y' => $aData['y'],
00094                                            'SEARCH_PREFIX' => $aData['prefix'],
00095                                            'SEARCH_ROW' => (($i % 2) == 0) ? 0 : 1
00096                                         )
00097                                   );
00098         $strSearchList .= $oStyle->get_area ( 'ResultRow' );
00099         $i++;
00100     }
00101 
00102     $oStyle->addReplacements ( array ( 'SEARCH_X' => $intX,
00103                                        'SEARCH_Y' => $intY,
00104                                        'SEARCH_NAME' => $strName,
00105                                        'SEARCH_GUILD' => $strGuild,
00106                                        'SEARCH_GUILD_ID' => $intGuild,
00107                                        'SEARCH_RADIUS' => $intRadius,
00108                                        'SEARCH_ORDER' => $strOrder
00109                                     )
00110                               );
00111     // show result
00112     if ( $i==0 )
00113     {
00114         $strSearchResult = $oStyle->get_area ( 'NoResult' );
00115     }
00116     else
00117     {
00118         $oStyle->addReplacements ( array ( 'ROWS' => $strSearchList ) );
00119         $strSearchResult = $oStyle->get_area ( 'Result' );
00120     }
00121 }
00122 
00123 // display style
00124 $oStyle->addReplacements ( array ( 'SEARCH_RESULT' => $strSearchResult ) );
00125 $strTmpl_inhalt = $oStyle->get_area( 'Input' );
00126 output();

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