00001 <?php
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 require_once('./general.php');
00028
00029
00030 $oStyle->setTemplate( 'profile.html' );
00031 $oStyle->split_area('Profile');
00032
00033
00034
00035 if(isset($_POST['action'])) $action = $_POST['action'];
00036 elseif(isset($_GET['action'])) $action = $_GET['action'];
00037 else $action = '';
00038
00039 $intSizeX = isset($_POST['sx']) ? intval( $_POST['sx'] ) : $oUser->intSizeX;
00040 $intSizeY = isset($_POST['sy']) ? intval( $_POST['sy'] ) : $oUser->intSizeY;
00041
00042
00043 $intHomeX = (isset($_POST['hx']) && !$oUser->isAdmin( 'limit_view' )) ? intval( $_POST['hx'] ) : $oUser->intHomeX;
00044 $intHomeY = (isset($_POST['hy']) && !$oUser->isAdmin( 'limit_view' )) ? intval( $_POST['hy'] ) : $oUser->intHomeY;
00045
00046 $intShowUnit = isset($_POST['su']) ? intval( $_POST['su'] ) : $oUser->intUnit;
00047 $booFog = $action == 'save' ? isset($_POST['fog']) : $oUser->intFog;
00048 $intSight = $action == 'save' ? intval($_POST['town_sight']) : $oUser->intTownSight;
00049 $booFill = $action == 'save' ? isset($_POST['town_fill']) : $oUser->intTownFill;
00050
00051 $strPlayer = (isset($_POST['player']) && !$oUser->isAdmin( 'limit_view' )) ? trim( $_POST['player'] ) : $oUser->strPlayer;
00052
00053
00054 $strPassA = isset($_POST['pass1']) ? $_POST['pass1'] : '';
00055 $strPassB = isset($_POST['pass2']) ? $_POST['pass2'] : '';
00056
00057 $intNewStyle = isset($_POST['new_style']) ? intval( $_POST['new_style'] ) : $intStyle;
00058
00059
00060 $intUserId = $oUser->intUserID;
00061
00062 $strMessage = '';
00063
00064
00065 if( $action == 'save' )
00066 {
00067 $strUpdatePlayer = '';
00068 if( $strPlayer != $oUser->strPlayer || $oUser->strPlayer == '' )
00069 {
00070
00071 $aPlayer = $oMysql->query_first( "SELECT player_id FROM ".$oMysql->tblPlayer." WHERE name LIKE '".$strPlayer."' LIMIT 1;" );
00072 if( $aPlayer['player_id'] )
00073 {
00074 $strUpdatePlayer = ", player_id='".$aPlayer['player_id']."'";
00075 }
00076 else
00077 {
00079 }
00080 }
00081 $strPassChange = ( $strPassA != '' && $strPassA == $strPassB ) ? ", pass=MD5('$strPassA') " : '';
00082 $oLog->write( 'Profile-Update', 3 );
00083 $oMysql->query("UPDATE ".$oMysql->tblUser." ".
00084 "SET home_x='$intHomeX', home_y='$intHomeY', size_x='$intSizeX', size_y='$intSizeY', show_unit='$intShowUnit', show_fog='$booFog', show_town_sight='$intSight', show_town_fill='$booFill'".$strPassChange.$strUpdatePlayer.
00085 "WHERE user_id='$intUserId';");
00086
00087 $oUser->intHomeX = $intHomeX;
00088 $oUser->intHomeY = $intHomeY;
00089
00090 $strMessage = 'Daten geändert';
00091
00092 if( $strPassChange != '' )
00093 {
00094 $oMysql->query("SELECT * FROM ".$oMysql->tblUser." WHERE user_id=$intUserId;");
00095 $aRow = $oMysql->fetch_assoc();
00096 if( $aRow['pass'] != '')
00097 {
00098 setcookie( $strCookiePrefix . '[pass]', $aRow['pass'], time()+365*24*60*60);
00099 $strMessage .= '<br />Das Passwort wurde geändert!';
00100 }
00101 }
00102
00103 if( $intNewStyle != $intStyle )
00104 {
00105 setcookie( $strCookiePrefix . '[style]', $intNewStyle, time()+365*24*60*60);
00106
00107 $intStyle = $intNewStyle;
00108 }
00109 }
00110
00111
00112 $strHome = '';
00113 if( !$oUser->isAdmin( 'limit_view' ) )
00114 {
00115 $oStyle->addReplacements( array( 'P_HX' => $intHomeX, 'P_HY' => $intHomeY, 'P_PLAYER' => $strPlayer ) );
00116 $strHome = $oStyle->get_area( 'ProfileHome' );
00117 }
00118
00119
00120 $strOptions = '';
00121 foreach( $aTemplate['styles'] AS $intCurrent => $aStyle )
00122 {
00123 $oStyle->addReplacements( array( 'OPT_ID' => $intCurrent,
00124 'OPT_SEL' => ($intStyle==$intCurrent) ? ' selected="selected"' : '',
00125 'OPT_NAME' => $aStyle[2] ) );
00126 $strOptions .= $oStyle->get_area( 'Option' );
00127 }
00128
00129 $oStyle->addReplacements( array( 'SEL_NAME' => 'new_style',
00130 'SEL_OPTIONS' => $strOptions ) );
00131 $strSelect = $oStyle->get_area( 'Select' );
00132
00133 $oStyle->addReplacements( array( 'P_HOME' => $strHome,
00134 'P_SX' => $intSizeX,
00135 'P_SY' => $intSizeY,
00136 'P_FOG' => ($booFog != 0) ? ' checked="checked"' : '',
00137 'P_TSIGHT' => $intSight,
00138 'P_FILL' => ($booFill != 0) ? ' checked="checked"' : '',
00139 'P_UNIT' => $intShowUnit,
00140 'P_STYLE' => $strSelect,
00141 'P_MSG' => $strMessage ) );
00142
00143
00144 $strTmpl_inhalt = $oStyle->get_area( 'Profile' );
00145 output();