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

profile.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( 'profile.html' );
00031 $oStyle->split_area('Profile');
00032 
00033 
00034 // get variables
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 // if the user has limited view, he is not allowed to change his home coords
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 // password
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 // User Id of current user
00060 $intUserId = $oUser->intUserID;
00061 
00062 $strMessage = '';
00063 
00064 // Forumlar wird gespeichert?
00065 if( $action == 'save' )
00066 {
00067     $strUpdatePlayer = '';
00068     if( $strPlayer != $oUser->strPlayer || $oUser->strPlayer == '' )
00069     {
00070         // player was changed, get the player id
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&auml;ndert';
00091     // write new pass to cookie
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&auml;ndert!';
00100         }
00101     }
00102 
00103     if( $intNewStyle != $intStyle )
00104     {
00105         setcookie( $strCookiePrefix . '[style]', $intNewStyle, time()+365*24*60*60);
00106         // change current style
00107         $intStyle = $intNewStyle;
00108     }
00109 }
00110 
00111 // users with limited view are not allowed to change their home coordinates
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 // build select box for the styles
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 // get the area
00144 $strTmpl_inhalt = $oStyle->get_area( 'Profile' );
00145 output();

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