Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $uid = (int)$_GET['uid'];
- if(!empty($uid)){
- $usuarios = mysql_query("SELECT * FROM ".TBL_USERS." WHERE id = '".$uid."' LIMIT 1") or die(mysql_error());
- $usuario = mysql_fetch_assoc($usuarios);
- } else {
- $usuarios = mysql_query("SELECT * FROM ".TBL_USERS." WHERE id = '".$id."' LIMIT 1") or die(mysql_error());
- $usuario = mysql_fetch_assoc($usuarios);
- }
- if(isset($_GET['tab'])){
- if($_GET['tab'] < 1 || $_GET['tab'] > 3 ){
- header("Location: perfil.php?uid=".$usuario['id']."");
- $tab = 0;
- exit;
- } else {
- $tab = (int)$_GET['tab'];
- }
- }
- ///////////////////////////////////////// PERFIL /////////////////////////////////////////////////
- if($tab == 1){
- if(!empty($_POST['ok'])){
- $city = $_POST['cidade'];
- $desc1 = $_POST['desc1'];
- $desc2 = $_POST['desc2'];
- $namevillage = $_POST['namevillage'];
- $sex = $_POST["sexo"];
- $day = $_POST["dia"];
- $month = $_POST["mes"];
- $year = $_POST["ano"];
- $date = "$day-$month-$year";
- mysql_query("UPDATE ".TBL_USERS." SET city = '".$city."', description1 = '".$desc1."', description2 = '".$desc2."', sex = '".$sex."', date = '".$date."', email = '".$email."' WHERE id = '".$user['id']."' LIMIT 1") or die(mysql_error());
- mysql_query("UPDATE ".TBL_VILLAGES." SET name = '".$namevillage."' WHERE uid = '".$usuario['id']."' LIMIT 1") or die(mysql_error());
- header("location: perfil.php");
- } else {
- $city = $user['city'];
- $desc1 = $user['description1'];
- $desc2 = $user['description2'];
- $namevillage = $user['name'];
- $sex = $user['sex'];
- $date = explode("-", $user['date']);
- $day = $date[0];
- $month = $date[1];
- $year = $date[2];
- }
- }
- ///////////////////////////////////////// CONTA /////////////////////////////////////////////////
- if($tab == 2){
- if(!empty($_POST['oldpass'])){
- $oldpass = $_POST['oldpass'];
- $newpass1 = $_POST['newpass1'];
- $newpass2 = $_POST['newpass2'];
- if($oldpass != $user['password'] && !empty($oldpass)){
- $erro['oldpass'] = "<li>(A senha antiga est� incorreta!)</li>";
- } elseif($newpass1 != $newpass2 && !empty($newpass1) && !empty($newpass2)){
- $erro['newpass1'] = "<li>(As novas senhas est�o diferentes!)</li>";
- } elseif($oldpass == $user['password'] && $newpass1 == $newpass2){
- mysql_query("UPDATE ".TBL_USERS." SET password = '".$newpass2."' WHERE id = '".$user['id']."' LIMIT 1") or die(mysql_error());
- }
- }
- if(!empty($_POST['email1'])){
- $email1 = addslashes($_POST['email1']);
- $email2 = addslashes($_POST['email2']);
- $email_check1 = preg_match("/^[a-z0-9_\.-]+@([a-z0-9]+([\-]+[a-z0-9]+)*\.)+[a-z]{2,7}$/i", $email1);
- $email_check2 = preg_match("/^[a-z0-9_\.-]+@([a-z0-9]+([\-]+[a-z0-9]+)*\.)+[a-z]{2,7}$/i", $email2);
- if($email_check1 != 1 || $email_check2 != 1 || strlen($email1) < 6 || strlen($email2) < 6){
- $erro['mail'] = "<li>(E-mail inv�lido)</li>";
- } elseif($email1 != $user['email']){
- $erro['mail'] = "<li>(Este email n�o consta no Banco de Dados)</li>";
- } else {
- mysql_query("UPDATE ".TBL_USERS." SET email = '".$email2."' WHERE id = '".$user['id']."' LIMIT 1") or die(mysql_error());
- }
- }
- if(!empty($_POST['sitter'])){
- $sitter = addslashes($_POST['sitter']);
- $users_sitter = mysql_query("SELECT * FROM ".TBL_USERS." WHERE username = '".$sitter."' LIMIT 1") or die(mysql_error());
- $sitters = mysql_query("SELECT * FROM ".TBL_SITTER_SAMEPC." WHERE username = '".$sitter."' AND type = '1' LIMIT 1") or die(mysql_error());
- if(mysql_num_rows($users_sitter) >= 1 && mysql_num_rows($sitters) == 0 && $sitter != $user['username']){
- mysql_query("INSERT INTO ".TBL_SITTER_SAMEPC." (uid,username,type) VALUES ('".$user['id']."', '".$sitter."', 1)") or die(mysql_error());
- } elseif($sitter == $user['username']) {
- $erro['sitter'] = "<li>(Erro! Voc� n�o pode adicionar a si mesmo)</li>";
- } elseif(mysql_num_rows($users_sitter) == 0) {
- $erro['sitter'] = "<li>(Este usu�rio n�o existe!)</li>";
- }
- }
- if(isset($_GET['id']) && $_GET['type'] == "1" && $_GET['e'] == "1"){
- $userid = (int)$_GET['id'];
- $users_sitter = mysql_fetch_assoc(mysql_query("SELECT * FROM ".TBL_USERS." WHERE id = '".$userid."' LIMIT 1")) or die(mysql_error());
- $sitters = mysql_query("SELECT * FROM ".TBL_SITTER_SAMEPC." WHERE uid = '".$user['id']."' AND username = '".$users_sitter['username']."' AND type = '1' LIMIT 1") or die(mysql_error());
- if(mysql_num_rows($sitters) >= 0){
- mysql_query("DELETE FROM ".TBL_SITTER_SAMEPC." WHERE uid = '".$user['id']."' AND username = '".$users_sitter['username']."' AND type = '1' LIMIT 1") or die(mysql_error());
- }
- }
- if(isset($_GET['id']) && $_GET['type'] == "1" && $_GET['f'] == "1"){
- $userid = (int)$_GET['id'];
- $users_sitter = mysql_fetch_assoc(mysql_query("SELECT * FROM ".TBL_USERS." WHERE id = '".$userid."' LIMIT 1")) or die(mysql_error());
- $sitters = mysql_query("SELECT * FROM ".TBL_SITTER_SAMEPC." WHERE uid = '".$users_sitter['id']."' AND username = '".$user['username']."' AND type = '1' LIMIT 1") or die(mysql_error());
- if(mysql_num_rows($sitters) >= 0){
- mysql_query("DELETE FROM ".TBL_SITTER_SAMEPC." WHERE uid = '".$users_sitter['id']."' AND username = '".$user['username']."' AND type = '1' LIMIT 1") or die(mysql_error());
- }
- }
- if(!empty($_POST['same_pc'])){
- $same_pc = addslashes($_POST['same_pc']);
- $users_samepc = mysql_query("SELECT * FROM ".TBL_USERS." WHERE username = '".$same_pc."' LIMIT 1") or die(mysql_error());
- $samepc = mysql_query("SELECT * FROM ".TBL_SITTER_SAMEPC." WHERE username = '".$same_pc."' AND type = '2' LIMIT 1") or die(mysql_error());
- if(mysql_num_rows($users_samepc) >= 1 && mysql_num_rows($samepc) == 0 && $same_pc != $user['username']){
- mysql_query("INSERT INTO ".TBL_SITTER_SAMEPC." (uid,username,type) VALUES ('".$user['id']."', '".$same_pc."', 2)") or die(mysql_error());
- } elseif($same_pc == $user['username']) {
- $erro['samepc'] = "<li>(Erro! Voc� n�o pode adicionar a si mesmo)</li>";
- } elseif(mysql_num_rows($users_samepc) == 0) {
- $erro['samepc'] = "<li>(Este usu�rio n�o existe!)</li>";
- }
- }
- if(isset($_GET['id']) && $_GET['type'] == "2" && $_GET['g'] == "1"){
- $userid = (int)$_GET['id'];
- $users_samepc = mysql_fetch_assoc(mysql_query("SELECT * FROM ".TBL_USERS." WHERE id = '".$userid."' LIMIT 1")) or die(mysql_error());
- $sitters = mysql_query("SELECT * FROM ".TBL_SITTER_SAMEPC." WHERE uid = '".$user['id']."' AND username = '".$users_samepc['username']."' AND type = '2' LIMIT 1") or die(mysql_error());
- if(mysql_num_rows($sitters) >= 0){
- mysql_query("DELETE FROM ".TBL_SITTER_SAMEPC." WHERE uid = '".$user['id']."' AND username = '".$users_samepc['username']."' AND type = '2' LIMIT 1") or die(mysql_error());
- }
- }
- }
- include("template/header.php");
- ?>
- <div id="content" class="player">
- <h1>Perfil do jogador</h1>
- <?php if($usuario['id'] == $user['id']){ ?>
- <div id="textmenu">
- <a href="perfil.php?uid=<?php echo $usuario['id'];?>" <?php if(!isset($uid) || !empty($uid) || empty($tab)){ echo "class=\"selected\"";}?>>Vis�o geral</a> |
- <a href="perfil.php?tab=1" <?php if($tab == "1"){ echo "class=\"selected\"";}?>>Perfil</a> |
- <a href="perfil.php?tab=2" <?php if($tab == "2"){ echo "class=\"selected\"";}?>>Conta</a>
- <?php /*?>
- <a href="perfil.php?tab=2" <?php if($tab == "2"){ echo "class=\"selected\"";}?>>Prefer�ncias</a> |
- <a href="perfil.php?tab=3" <?php if($tab == "3"){ echo "class=\"selected\"";}?>>Pacote gr�fico</a>
- <?php */ ?>
- </div>
- <?php }
- if(!isset($uid) || !empty($uid) || empty($tab)){
- ?>
- <table id="profile" cellpadding="1" cellspacing="1">
- <thead>
- <tr>
- <th colspan="2">Jogador <?php echo $usuario['username'];?></th>
- </tr>
- <tr>
- <td>Detalhes</td>
- <td>Descri��o:</td>
- </tr>
- </thead><tbody>
- <tr>
- <td class="empty"></td><td class="empty"></td>
- </tr>
- <tr>
- <td class="details">
- <table cellpadding="0" cellspacing="0">
- <tr>
- <th>Classifica��o</th>
- <td>X</td>
- </tr>
- <tr>
- <th>Tribo:</th>
- <td><?php echo Tribo($usuario['tribe']);?></td>
- </tr>
- <tr>
- <th>Alian�a:</th>
- <td><?php echo Ally($usuario['id']);?></td>
- </tr>
- <tr>
- <th>Aldeias:</th>
- <td><?php echo NumAldeias($usuario['id']);?></td>
- </tr>
- <tr>
- <th>Popula��o:</th>
- <td><?php echo PopTotal($usuario['id']);?></td>
- </tr><tr>
- <td colspan="2" class="empty"></td>
- </tr>
- <tr>
- <td colspan="2">
- <?php
- if($usuario['id'] == $user['id']){
- echo "<a href=\"spieler.php?s=1\">» Alterar perfil</a>";
- } elseif($usuario['id'] != $user['id']) {
- echo "<a href=\"nachrichten.php?t=1&id=".$usuario['id']."\">» Escrever mensagem</a>";
- }
- ?>
- </td>
- </tr>
- <tr>
- <td colspan="2" class="empty"></td>
- </tr>
- <tr>
- <td colspan="2" class="desc2">
- <?php echo $usuario['description2'];?>
- </td>
- </tr>
- </table>
- </td>
- <td class="desc1">
- <div><?php echo $usuario['description1'];?></div>
- </td>
- </tr>
- </tbody>
- </table><table cellpadding="1" cellspacing="1" id="villages">
- <thead>
- <tr>
- <th colspan="3">Aldeias:</th>
- </tr>
- <tr>
- <td>Nome</td>
- <td>Habitantes</td>
- <td>Coordenadas</td>
- </tr>
- </thead><tbody>
- <tr>
- <?php
- $villages = mysql_query("SELECT * FROM ".TBL_VILLAGES." WHERE uid = '".$usuario['id']."' LIMIT 1") or die(mysql_error());
- while($myvillages = mysql_fetch_assoc($villages)){
- if($myvillages['capital'] == "1"){
- $capital = "<span class=\"none3\">(Capital)</span>";
- } else {
- $capital = "";
- }
- $mapa = mysql_fetch_array(mysql_query("SELECT x,y FROM ".TBL_MAP." WHERE id = '".$myvillages['map']."' LIMIT 1")) or die(mysql_error());
- ?>
- <td class="nam"><a href="karte.php?d=169169&c=8d"><?php echo $village['name'];?></a> <?php echo $capital;?></td>
- <td class="hab"><?php echo $myvillages['pop'];?></td>
- <td class="aligned_coords">
- <div class="cox">(<?php echo $mapa['0'];?></div>
- <div class="pi">|</div>
- <div class="coy"><?php echo $mapa['1'];?>)</div>
- </td>
- <?php
- }
- ?>
- </tr>
- </tbody>
- </table>
- <?php } elseif($tab == "1"){?>
- <form action="perfil.php?tab=1" method="POST">
- <table cellpadding="1" cellspacing="1" id="edit"><thead>
- <tr>
- <th colspan="3">Jogador <?php echo $usuario['username'];?></th>
- </tr>
- <tr>
- <td colspan="2">Detalhes</td>
- <td>Descri��o:</td>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td colspan="2" class="empty"></td><td class="empty"></td></tr>
- <tr>
- <th>Data de nascimento:</th><td class="birth">
- <input tabindex="1" class="text day" type="text" name="dia" value="<?php echo $day;?>" maxlength="2" />
- <select tabindex="2" name="mes" size="" class="dropdown">
- <option value="00" <?php if($day == "00"){ echo "selected";}?>></option>
- <option value="01" <?php if($day == "01"){ echo "selected";}?>>Jan</option>
- <option value="02" <?php if($day == "02"){ echo "selected";}?>>Fev</option>
- <option value="03" <?php if($day == "03"){ echo "selected";}?>>Mar</option>
- <option value="04" <?php if($day == "04"){ echo "selected";}?>>Abr</option>
- <option value="05" <?php if($day == "05"){ echo "selected";}?>>Mai</option>
- <option value="06" <?php if($day == "06"){ echo "selected";}?>>Jun</option>
- <option value="07" <?php if($day == "07"){ echo "selected";}?>>Jul</option>
- <option value="08" <?php if($day == "08"){ echo "selected";}?>>Ago</option>
- <option value="09" <?php if($day == "09"){ echo "selected";}?>>Set</option>
- <option value="10" <?php if($day == "10"){ echo "selected";}?>>Out</option>
- <option value="11" <?php if($day == "11"){ echo "selected";}?>>Nov</option>
- <option value="12" <?php if($day == "12"){ echo "selected";}?>>Dez</option>
- </select>
- <input tabindex="3" type="text" name="ano" value="<?php echo $year;?>" maxlength="4" class="text year">
- </td>
- <td rowspan="7" class="desc1"><textarea tabindex="7" name="desc1"><?php echo $desc1;?></textarea></td></tr>
- <tr><th>Sexo:</th>
- <td class="gend">
- <label><input class="radio" type="radio" name="sexo" value="0" <?php if($sex == "0"){ echo "checked";}?>>n.d.</label>
- <label><input class="radio" type="radio" name="sexo" value="1" <?php if($sex == "1"){ echo "checked";}?>>m</label>
- <label><input class="radio" type="radio" name="sexo" value="2" <?php if($sex == "2"){ echo "checked";}?>>f</label>
- </td></tr>
- <tr><th>Cidade:</th><td><input tabindex="5" type="text" name="cidade" value="<?php echo $city;?>" maxlength="30" class="text"></td></tr>
- <tr><td colspan="2" class="empty"></td></tr>
- <tr><th>Nome da aldeia:</th><td><input tabindex="6" type="text" name="namevillage" value="<?php echo $village['name'];?>" maxlength="20" class="text"></td></tr><tr><td colspan="2" class="empty"></td></tr>
- <tr><td colspan="2" class="desc2"><textarea tabindex="8" name="desc2"><?php echo $desc2;?></textarea></td></tr>
- </table>
- <p class="btn"><input type="image" value="1" tabindex="9" name="ok" id="btn_ok" class="dynamic_img" src="img/x.gif" alt="OK" /></p>
- </form>
- <?php } elseif($tab == "2"){
- $my_sitter = mysql_query("SELECT * FROM ".TBL_SITTER_SAMEPC." WHERE uid = '".$user['id']."' AND type = '1' LIMIT 2") or die(mysql_error());
- $sitter_row = mysql_num_rows($my_sitter);
- $sitters = mysql_query("SELECT * FROM ".TBL_SITTER_SAMEPC." WHERE username = '".$user['username']."' AND type = '1' LIMIT 2") or die(mysql_error());
- $sitters_row = mysql_num_rows($sitters);
- $same_pc_q = mysql_query("SELECT * FROM ".TBL_SITTER_SAMEPC." WHERE uid = '".$user['id']."' AND type = '2'") or die(mysql_error());
- $samepc_row = mysql_num_rows($same_pc_q);
- ?>
- <form action="perfil.php?tab=2" method="POST">
- <ul class="important">
- <?php echo $erro['oldpass'].$erro['newpass1'].$erro['mail'].$erro['sitter'].$erro['samepc'];?>
- </ul>
- <table cellpadding="1" cellspacing="1" id="change_pass" class="account">
- <thead>
- <tr>
- <th colspan="2">Alterar senha</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <th>Senha antiga:</th>
- <td><input class="text" type="password" name="oldpass" maxlength="20"></td>
- </tr>
- <tr>
- <th>Nova senha:</th>
- <td><input class="text" type="password" name="newpass1" maxlength="20"></td>
- </tr>
- <tr>
- <th>Nova senha:</th>
- <td><input class="text" type="password" name="newpass2" maxlength="20"></td>
- </tr>
- </tbody>
- </table>
- <table cellpadding="1" cellspacing="1" id="change_mail" class="account">
- <thead>
- <tr>
- <th colspan="2">Alterar e-mail</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td class="note" colspan="2">Por favor digite seu e-mail antigo e o e-mail atual. Voc� ir� receber um c�digo de confirma��o em ambos endere�os de e-mail, os quais dever�o ser digitados aqui.</td></tr>
- <tr>
- <th>E-Mail antigo:</th>
- <td><input class="text" type="text" name="email1" maxlength="50"></td>
- </tr>
- <tr>
- <th>E-Mail novo:</th>
- <td><input class="text" type="text" name="email2" maxlength="50"></td>
- </tr>
- </tbody>
- </table>
- <table cellpadding="1" cellspacing="1" id="sitter" class="account">
- <thead>
- <tr>
- <th colspan="2">Sitters da conta</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td class="note" colspan="2">Um sitter pode entrar na sua conta com o seu nome de usu�rio e a senha dele. Voc� pode ter no m�ximo dois sitters.</td>
- </tr>
- <tr>
- <th>Nome dos sitters:</th>
- <td><input class="text" type="text" name="sitter" maxlength="15" <?php if($sitter_row == 2){ echo "disabled";}?>><span class="count"><b><?php if($sitter_row == 0){ echo "<font color=\"#008000\">$sitter_row/2</font>";} elseif($sitter_row == 1){ echo "<font color=\"#D26900\">$sitter_row/2</font>";} elseif($sitter_row == 2){ echo "<font color=\"#800000\">$sitter_row/2</font>";}?></b></span></td>
- </tr>
- <tr>
- <td colspan="2" class="sitter">
- <?php if($sitter_row == 0){ ?>
- <span class="none">Voc� n�o tem sitters.</span>
- <?php } else {
- while($sitter_fetch = mysql_fetch_assoc($my_sitter)){
- $users = mysql_fetch_assoc(mysql_query("SELECT * FROM ".TBL_USERS." WHERE username = '".$sitter_fetch['username']."' LIMIT 1")) or die(mysql_error());
- ?>
- <div>
- <a href="perfil.php?tab=2&id=<?php echo $users['id'];?>&type=1&e=1"><img class="del" src="img/x.gif" title="Remover sitters" alt="Remover sitters" /></a>
- <a href="perfil.php?uid=<?php echo $users['id'];?>"><?php echo $users['username'];?></a>
- </div>
- <?php } } ?>
- </td>
- </tr>
- <tr>
- <td class="note" colspan="2">Voc� foi escolhido como sitter das seguintes contas.
- Pode cancelar com um clique no X vermelho.</td></tr>
- <tr>
- <td colspan="2" class="sitter">
- <?php if($sitters_row == 0){ ?>
- <span class="none">Voc� n�o � sitter.</span>
- <?php } else {
- while($sitter_fetch = mysql_fetch_assoc($sitters)){
- $users = mysql_fetch_assoc(mysql_query("SELECT * FROM ".TBL_USERS." WHERE id = '".$sitter_fetch['uid']."' LIMIT 1")) or die(mysql_error());
- ?>
- <div>
- <a href="perfil.php?tab=2&id=<?php echo $users['id'];?>&type=1&f=1"><img class="del" src="img/x.gif" title="Remover sitters" alt="Remover sitters" /></a>
- <a href="perfil.php?uid=<?php echo $users['id'];?>"><?php echo $users['username'];?></a>
- </div>
- <?php } } ?>
- </td>
- </tr>
- </table>
- <table cellpadding="1" cellspacing="1" id="same_pc" class="account">
- <thead>
- <tr>
- <th colspan="2">Mesmo PC em uso</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td class="note" colspan="2">Se voc� joga Travian com outras pessoas no mesmo PC, tem que inserir o nome das diferentes contas aqui. Essa op��o se aplica apenas para o mesmo computador, n�o rede.</td>
- </tr>
- <tr>
- <th>Nome do jogador</th>
- <td><input class="text" type="text" name="same_pc" maxlength="15" /></td>
- </tr>
- <tr>
- <td colspan="2" class="user">
- <?php if($samepc_row == 0){ ?>
- <span class="none">Voc� n�o tem jogadores adicionados ao Mesmo PC em Uso.</span>
- <?php } else {
- while($samepc_q = mysql_fetch_assoc($same_pc_q)){
- $users = mysql_fetch_assoc(mysql_query("SELECT * FROM ".TBL_USERS." WHERE username = '".$samepc_q['username']."' LIMIT 1")) or die(mysql_error());
- ?>
- <a href="perfil.php?tab=2&id=<?php echo $users['id'];?>&type=2&g=1"><img class="del" src="img/x.gif" title="Terminar com uso de mesmo PC" alt="Terminar com uso de mesmo PC" /></a>
- <a href="perfil.php?uid=<?php echo $users['id'];?>"><?php echo $users['username'];?></a>
- <?php } } ?>
- </td>
- </tr>
- </tbody>
- </table>
- <table cellpadding="1" cellspacing="1" id="del_acc" class="account">
- <thead>
- <tr>
- <th colspan="2">Cancelar conta</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td class="note" colspan="2">Voc� pode cancelar a sua conta aqui. Ap�s o pedido de cancelamento, voc� ter� apenas 24h para mudar de id�ia. A sua conta ser� definitivamente cancelada ap�s 3 dias.</td>
- </tr>
- <tr>
- <th>Cancelar conta?</th>
- <td class="del_selection">
- <label><input class="radio" type="radio" name="del" value="1"> sim</label>
- <label><input class="radio" type="radio" name="del" value="0" checked> n�o</label>
- </td>
- </tr>
- <tr>
- <th>Confirmar com a senha:</th>
- <td><input class="text" type="password" name="del_senha" maxlength="20" /></td>
- </tr>
- </tbody>
- </table>
- <p class="btn"><input type="image" value="" name="s1" id="btn_save" class="dynamic_img" src="img/x.gif" alt="salvar" /></p>
- </form>
- <?php } ?>
- </div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement