00001 <?php
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 require_once( './general.php' );
00026 require_once( './lib/guild.php' );
00027
00028 if( !$oUser->isAdmin( 'guild_list' ) )
00029 {
00030 die('Keine Admin Rechte.');
00031 }
00032
00033
00034 $oStyle->setTemplate('guild.html' );
00035 $oStyle->split_area('List');
00036 $oStyle->split_area('GuildRow');
00037 $oStyle->split_area('Edit');
00038 $oStyle->split_area('Add');
00039
00040 $oGuild = new Guild( $oMysql, $oLog, $oUser );
00041
00042
00043 if(isset($_POST['action'])) $action = $_POST['action'];
00044 elseif(isset($_GET['action'])) $action = $_GET['action'];
00045 else $action = 'list';
00046
00047
00048 if( $action == 'edit' && $oUser->isAdmin( 'guild_edit' ) )
00049 {
00050 if(isset($_POST['guildid'])) $intGuild = intval($_POST['guildid']);
00051 elseif(isset($_GET['guildid'])) $intGuild = intval($_GET['guildid']);
00052 else $intGuild = 0;
00053
00054 if( !isset($_POST['submit']) )
00055 {
00056 $aGuild = $oGuild->get( $intGuild );
00057 if( $aGuild === false )
00058 {
00059
00060 }
00061
00062
00063 $aDiplomacy = array( 0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => '', 6 => '', 7 => '', 8 => '' );
00064 $aDiplomacy[$aGuild['diplomacy']] = ' checked="checked"';
00065 $oStyle->addReplacements( array( 'GUILD_NAME' => htmlspecialchars( $aGuild['name'] ),
00066 'GUILD_TAG' => htmlspecialchars( $aGuild['tag'] ),
00067 'GUILD_BGCOLOR' => $aGuild['bgcolor'],
00068 'GUILD_FGCOLOR' => $aGuild['fgcolor'],
00069 'GUILD_ID' => $aGuild['guild_id'],
00070 'DIPLOMACY_0' => $aDiplomacy[0],
00071 'DIPLOMACY_1' => $aDiplomacy[1],
00072 'DIPLOMACY_2' => $aDiplomacy[2],
00073 'DIPLOMACY_3' => $aDiplomacy[3],
00074 'DIPLOMACY_4' => $aDiplomacy[4],
00075 'DIPLOMACY_5' => $aDiplomacy[5],
00076 'DIPLOMACY_6' => $aDiplomacy[6],
00077 'DIPLOMACY_7' => $aDiplomacy[7],
00078 'DIPLOMACY_8' => $aDiplomacy[8]
00079 )
00080 );
00081 }
00082 else
00083 {
00084
00085 $strName = (isset($_POST['guild_name'])) ? $_POST['guild_name'] : '';
00086 $strTag = (isset($_POST['guild_tag'])) ? $_POST['guild_tag'] : '';
00087 $strFgColor = (isset($_POST['guild_fgcolor'])) ? str_replace( '#', '', $_POST['guild_fgcolor'] ) : '';
00088 $strBgColor = (isset($_POST['guild_bgcolor'])) ? str_replace( '#', '', $_POST['guild_bgcolor'] ) : '';
00089 $intDiplomacy = (isset($_POST['guild_diplomacy'])) ? intval($_POST['guild_diplomacy']) : 0;
00090
00091 $oGuild->set( $intGuild, $strName, $strTag, $strFgColor, $strBgColor, $intDiplomacy );
00092
00093 $action = 'list';
00094 }
00095 }
00096
00097 if( $action == 'delete' && $oUser->isAdmin( 'guild_del' ) )
00098 {
00099
00100 if(isset($_POST['guildid'])) $intGuild = intval($_POST['guildid']);
00101 elseif(isset($_GET['guildid'])) $intGuild = intval($_GET['guildid']);
00102 else $intGuild = 0;
00103
00104 if( !$oGuild->delete( $intGuild ) )
00105 {
00106
00107 }
00108
00109 $action = 'list';
00110 }
00111
00112 if( $action == 'add' && $oUser->isAdmin( 'guild_add' ) )
00113 {
00114 if( isset( $_POST['submit'] ) )
00115 {
00116
00117
00118 $strName = (isset($_POST['guild_name'])) ? $_POST['guild_name'] : '';
00119 $strTag = (isset($_POST['guild_tag'])) ? $_POST['guild_tag'] : '';
00120 $strFgColor = (isset($_POST['guild_fgcolor'])) ? str_replace( '#', '', $_POST['guild_fgcolor'] ) : '';
00121 $strBgColor = (isset($_POST['guild_bgcolor'])) ? str_replace( '#', '', $_POST['guild_bgcolor'] ) : '';
00122 $intDiplomacy = (isset($_POST['guild_diplomacy'])) ? intval($_POST['guild_diplomacy']) : 0;
00123
00124 if( !$oGuild->add( $strName, $strTag, $strFgColor, $strBgColor, $intDiplomacy ) )
00125 {
00126
00127 }
00128
00129 $action = 'list';
00130 }
00131 }
00132
00133
00134 if( $action == 'list' )
00135 {
00136 $aGuilds = $oGuild->getAll();
00137 $i = 0;
00138 $strGuildList = '';
00139 foreach( $aGuilds AS $aData )
00140 {
00141 $oStyle->addReplacements( array( 'GUILD_ID' => $aData['guild_id'] ) );
00142
00143 $strGuildEdit = '';
00144 $strGuildDel = '';
00145 if( $aData['guild_id'] > 1 )
00146 {
00147 $strGuildEdit = $oUser->isAdmin( 'guild_edit' ) ? $oStyle->get_area( 'ListEditLink' ) : '';
00148 $strGuildDel = $oUser->isAdmin( 'guild_del' ) ? $oStyle->get_area( 'ListDelLink' ) : '';
00149 }
00150 $oStyle->addReplacements( array( 'DIPLOMACY_FGCOLOR' => $aDiploFgColor[$aData['diplomacy']],
00151 'DIPLOMACY_BGCOLOR' => $aDiploBgColor[$aData['diplomacy']],
00152 'GUILD_NAME' => ($aData['name']) ? $aData['name'] : ' ',
00153 'GUILD_FGCOLOR' => $aData['fgcolor'],
00154 'GUILD_BGCOLOR' => $aData['bgcolor'],
00155 'GUILD_TAG' => $aData['tag'] != '' ? '['.$aData['tag'].']' : '--',
00156 'GUILD_MEMBERS' => $aData['members'],
00157 'GUILD_TOWNS' => $aData['towns'],
00158 'GUILD_EDIT' => $strGuildEdit.$strGuildDel,
00159 'GUILD_ROW' => intval(($i % 2) == 0)
00160 )
00161 );
00162 $strGuildList .= $oStyle->get_area( 'GuildRow' );
00163 $i++;
00164 }
00165
00166
00167 $strGuildAdd = ( $oUser->isAdmin( 'guild_add' ) ) ? $oStyle->get_area( 'ListAddLink' ) : '';
00168 $oStyle->addReplacements( array( 'GUILD_RESULT' => $strGuildList,
00169 'GUILD_ADD' => $strGuildAdd ) );
00170 }
00171
00172
00173 $strTmpl_inhalt = $oStyle->get_area( ucfirst($action) );
00174 output();