1. Este site usa cookies. Ao continuar a usar este site está a concordar com o nosso uso de cookies. Saber Mais.

[HELP]PHP Session Vars

Discussão em 'Web Development' iniciada por Sasukez0r, 1 de Março de 2009. (Respostas: 18; Visualizações: 1311)

  1. Sasukez0r

    Sasukez0r Power Member

    Alguem poderá saber o problema das variaveis session não serem passadas para outra página =S
     
  2. tonebiclas

    tonebiclas Power Member

    inicias a sessão em todas as páginas ?
     
  3. Sasukez0r

    Sasukez0r Power Member

  4. fm.

    fm. Power Member

    Posta o código em que está a ocorrer essa dúvida, assim é mais fácil compreender o que está a falhar.
     
  5. Sasukez0r

    Sasukez0r Power Member

    loginvalidation.php
    Código:
    <?php
    session_start();
    include("functions/data_mysql.php");
    $link = mysql_connect($server,$user,$pass,$bd);
     include("functions/mysql.php");
    /*
     * Ficheiro responsável por todo o processo de validação de um
     * utilizador, encaminhando directamente para a pagina de
     * escolha/criação de personagens.
     */
    if(isset($_SESSION['cidade'])){
    $_SESSION['cidade'] = 0;
    }
    ?>
    <html>
    <title>Be Eternal God</title>
    <head>
    <link type="text/css" rel="stylesheet" id="style">
    <script>
        function disp_confirm(cod)
        {
            var name=confirm("Tens a certeza que dejesas apagar a personagem?")
        if (name==true){
            window.location="loginvalidation.php?d=" + cod        
        }
        else{
            window.location="loginvalidation.php"
        }
        }
    </script>
    </head>
    <body vlink="#FFFFFF" alink="#FFFFFF" link="#FFFFFF">
    <?php
    if($_GET['d']){
        $cod_del = $_GET['d'];
        
            $stfu = ownsql("SELECT n_mochila, n_casa FROM jogador WHERE cod_jogador='$cod_del'");
            $stuff = mysql_fetch_array($stfu);
            ownsql("DELETE FROM mochila_itens WHERE n_mochila='$stuff[0]'");
            ownsql("DELETE FROM casa_itens WHERE n_casa='$stuff[1]'");
            ownsql("DELETE FROM casa WHERE cod_jogador='$cod_del'");
            ownsql("DELETE FROM mochila WHERE cod_jogador='$cod_del'");
            ownsql("DELETE FROM skillp_player WHERE cod_jogador='$cod_del'");
            ownsql("DELETE FROM skilla_player WHERE cod_jogador='$cod_del'");
            ownsql("DELETE FROM jogador WHERE cod_jogador='$cod_del'");
    
    }
        
    
    if (!isset ($_SESSION['user'])){
         if($_POST['username']){
            $user = $_POST['username'];
        }
        if($_POST['pass']){
            $pass = $_POST['pass'];
        }
     }else{
         $user = $_SESSION['user'];
        $pass = $_SESSION['pass'];
     }
     $result = ownsql("SELECT login,password FROM conta WHERE login='$user' AND password='$pass'");
     $data = mysql_fetch_row($result);
     $_SESSION['user']=$data[0];
     $_SESSION['pass']=$data[1]; 
     if(mysql_num_rows($result)==0){
     
             header ("Location: loginerror.php");
     }else{ /*Login executado correctamente, Criação de novas personagens
             * ou escolha de uma jogável */
         if($_POST['skin']){
                $skin = $_POST['skin'];
                $qskin = ownsql("UPDATE conta SET skin = '$skin' WHERE login='$user'");
                $_SESSION['skin'] = $skin;
        }
        $qlol = ownsql("SELECT cod_conta, skin FROM conta WHERE login='$user'");
         $lol = mysql_fetch_array($qlol);
         $_SESSION['cod'] = $lol[0];
        $_SESSION['skin'] = $lol[1];
        echo $lol[1];
        echo $_SESSION['skin']."<br>";
        echo $lol[0];
        echo $_SESSION['cod'];
        echo "<script type=\"text/javascript\">document.getElementById(\"style\").href = \"../css/".$lol[1]."\";</script>";
        echo "<center><table id='texto' border=1 bgcolor=\"000000\">" .
              "<tr>" .
              "    <td>" .
              "        <table id='texto' border=0 border=0 width=\"468\">" .
              "            <tr>" .
              "                <td>" .
              "                        <div id=\"texto\">";
                                     $cod = $_SESSION['cod'];
                                     $result = ownsql("SELECT nivel,raca,dinheiro,img,nome,status,cod_jogador FROM jogador WHERE cod_conta='$cod'");
                                     echo "<center><div id=\"botao_char\"></div></center>";
                                            while($row = mysql_fetch_array($result)){
                                                 echo "<br><br><table id='texto' border=1 align=\"center\">";
                                                 if($row[3]){ //se ouve imagem constroi a célula para ela
                                                     echo"<tr>" .
                                                         "    <td>" .
                                                         "        <img src = \"../images/chars/".$row[3]."\"></img>" .
                                                         "    </td>" .
                                                         "</tr>" ;                                             }
                                                    echo "<tr>" .
                                                         "    <td>" .
                                                         "        <div id=\"texto\"><b>Nome: </div>" .
                                                         "    </td>" .
                                                         "    <td>" .
                                                         "            <div id=\"texto\">".$row[4]."</div>" .
                                                         "    </td>" .
                                                         "</tr>".
                                                         "<tr>" .
                                                         "    <td>" .
                                                         "        <div id=\"texto\"><b>Nível: </div>" .
                                                         "    </td>" .
                                                         "    <td>" .
                                                         "        <div id=\"texto\">".$row[0]."</div>" .
                                                         "    </td>" .
                                                         "</tr>" .
                                                         "<tr>" .
                                                         "    <td>" .
                                                         "        <div id=\"texto\"><b>Raca: </div>" .
                                                         "    </td>" .
                                                         "    <td>" .
                                                         "        <div id=\"texto\">".$row[1]."</div>" .
                                                         "    </td>" .
                                                         "</tr>" .
                                                         "<tr>" .
                                                         "    <td>" .
                                                         "        <div id=\"texto\"><b>Dinheiro: </div>" .
                                                         "    </td>" .
                                                         "    <td><div id=\"texto\">".$row[2]."</div>" .
                                                         "    </td>" .
                                                         "</tr>" .
                                                         "<tr>" .
                                                         "    <td>" .
                                                         "        <div id=\"texto\"><b>Status: </div>" .
                                                         "    </td>" .
                                                         "    <td>" .
                                                         "        ";
                                                                  if($row[5]==1){ 
                                                                      echo "<div id=\"texto\">Vivo</div>" .
                                                                                        "</td>" .
                                                                                        "</tr>" .
                                                                                        "</table>" .
                                                                                        "<center><br><a href=../home.php?inc=inicio.php&cod=".$row[6]."> Entrar </a> / ";
                            echo "<a onclick=\"disp_confirm('".$row[6]."')\"> Apagar </a><br><hr></center>";
                                                                  }
                                                                 else{ 
                                                                     echo "<div id=\"texto\">Morto</div>" .
                                                                          "    </td>" .
                                                                          "</tr>" .
                                                                          "</table><hr>";
                                                                     }
                                                     }
         echo "                </td>" .
              "            </tr>" .
              "        </table>" .
              "    </td>" .
              "    <td align=\"right\" valign=\"top\"><br><br>" .
              "        <form method=\"POST\" name=\"newchar\" action=\"charvalidate.php\">" .
              "        <table id='texto' border=1 width=\"200\">" .
              "            <tr>" .
              "                <td><img src=\"../home_layout/botoes/new.jpg\"></td>" .
              "            </tr>" .
              "            <tr>" .
              "                <td><div id=\"texto\"><center><b>Nome: </b></center></div></td>" .
              "                <td><INPUT TYPE=\"text\" name=\"nome\"></td>" .
              "            </tr>" .
              "            <tr>".
             "            <td><center><input type=\"submit\" value=\"Criar\" /></center></td>" .
             "            </tr>" .
              "        </table></form>" .
             "      <a href=\"logout.php\"><div id=\"texto\"><center><b>Log Out</b></center><div></a>
                     <center><br><br><a href=\"loginvalidation.php?op=1\"><b>Opcções da Conta</b></a></center>";
            if($_POST['new_pass']){
                if($_POST['check_new_password']){
                    if($_POST['check_new_password']==$_POST['new_pass']){
                        $pass = $_POST['new_pass'];
                        $qpass = ownsql("UPDATE conta SET password = '$pass' WHERE cod_conta = '$cod'");
                        echo "<center><font color=\"green\"><b>Password Alterada</b></font></center>";
                        $_SESSION['pass'] = $pass;
                    }else{
                        echo "<center><font color=\"red\"><b>As passwords não coincidem</b></font></center>";
                    }
                }else{
                    echo "<center><font color=\"red\"><b>Não introduziu a password de verificação</b></font></center>";
                }
            }
            if($_POST['new_email']){
                $email = $_POST['new_mail'];
                if(strlen($email)>15){
                    echo "<center><font color=\"red\"><b>O numero de caracteres do email ultrapassa o limite</b></font></center>";
                }else{
                        $qmail = ownsql("UPDATE conta SET email = '$mail' WHERE cod_conta='$cod'");
                        echo "<center><font color=\"green\"><b>O email foi actualizado</b></font></center>";
                    }
            }
            if($_POST['skin']){
                $skin = $_POST['skin'];
                $qskin = ownsql("UPDATE conta SET skin = '$skin' WHERE cod_conta='$cod'");
                $_SESSION['skin'] = $skin;
                echo "<center><font color=\"green\"><b>A Skin foi alterada </b></font></center>";
            }
            if($_GET['op']){
                echo "<form method=\"post\" action=\"loginvalidation.php\" name=\"alteracoes\">";
                echo "<br><hr><center>
                        <table id='texto'>
                            <tr>
                                <td><div id=\"texto\">Nova Password: </div></td><td><input type=\"password\" name=\"new_pass\"></td>
                            </tr>
                            <tr>
                                <td><div id=\"texto\">Confirmar Nova Password: </div></td><td><input type=\"password\" name=\"check_new_password\"></td>
                            </tr>
                            <tr>
                                <td><div id=\"texto\">Novo Email: </div></td><td><input type=\"text\" name=\"new_email\"></td>
                            </tr>";
                            echo "<tr><td><div id=\"texto\">Temas: </div></td><td><select name=\"skin\">";
                            if ($handle = opendir('../css')) {
                                while (false !== ($file = readdir($handle))) {
                                    if ($file != "." && $file != "..") {
                                        echo "<option value=\"".$file."\">".$file;
                                    }
                                }
                                closedir($handle);
                            }
    
                            echo "</select></td></tr></table>";
                            echo "<input type=\"submit\" name=\"alt\" value=\"Enviar\">
                                  &nbsp;&nbsp; / &nbsp;&nbsp;
                                  <input type=\"reset\" value=\"Limpar\">";
            }
            echo "</td></tr></table>";
    }
    ?>
    <?
    mysql_close();
    ?>
    </body>
    </html>
    home.php

    Código:
    <?
        ob_start();
        session_start();
    
        /*
         *IMPORTANTE: Este script tem as seguintes variáveis reservadas:
         *              $row; / $result / $nome / $player / $guild / $cod / $included
         *              OS SCRIPTS QUE IRÃO SER INCLUIDOS, NÃO PODEM TRABALHAR COM VARIÁVEIS
         *              COM OS MESMO NOMES DAS VARIÁVEIS RESERVADAS ACIMA INDICADAS!!!
         *row[0] - PK / row[1] - PVP / row[2] - Nível / row[3] - cod_guild
         *row[4] - nome / row[5] - raca / row[6] - HP / row[7] - job / row[8] - gold / row[9] - access / row[10] - status
         */
        include("php/functions/data_mysql.php");
        $link = mysql_connect($server,$user,$pass,$bd);
        include("php/functions/mysql.php");
        include("php/functions/anticheat01.php");
        $erro = 0;
        if ($row[0] != $_SESSION['cod']){
            $erro = 1;
        }    
        if ($_SESSION['items'] != 0){
            if ($_GET['inc'] != 'drops.php'){
                $_SESSION['items'] = 0;
            }
        }
        $_SESSION['player'] = $cod;
        $player = $_SESSION['player'];
        $result = ownsql("SELECT PK,PVP,nivel,cod_clan,nome,raca,HP_actual,job,dinheiro,acesso,status,zona FROM jogador WHERE cod_jogador='$player'");
        $row = mysql_fetch_row($result);
        include("php/functions/skills.php");
        $skin = $_SESSION['skin'];
        if ($row[10] == 0){
            $erro = 1;
            
        }
        
           
           if ($row[5] == 'Neutral' && $row[2] >= 10){
            if ($_GET['inc'] != 'race.php'){
                header("Location: home.php?inc=race.php&cod=".$player."");
            }
        }
        if ($_SESSION['mob'] != 0){
            if ($_GET['inc'] != 'teleporting.php' && $_GET['inc'] != 'pvm.php' && $_GET['inc'] != 'pk.php' && $_GET['inc'] != 'mochila.php' && $_GET['inc'] != 'pvp_war.php'){
                header("Location: home.php?inc=teleporting.php&cod=".$player."&map=".$row[11]."");
            }
        }
    if ($erro == 1){
            header("Location: php/loginvalidation.php");
        }
    
             
            //UPDATE DAS MENSAGENS
        $qdados = ownsql("SELECT btodos, bnenhum, bclan, numero FROM jogador WHERE cod_jogador = '$player'");
        $dados = mysql_fetch_row($qdados);
        if($dados[1]!=1 && $dados[0]==1){
            $qdest = ownsql("SELECT nome FROM jogador WHERE cod_jogador = '$player'");
            $dest = mysql_fetch_row($qdest);
            $qmsgs = ownsql("SELECT COUNT(*) FROM mensagens WHERE destinatario = '$dest[0]' AND lida=0");
        }
        if($dados[2]==1){
            $qdest = ownsql("SELECT nome, cod_clan FROM jogador WHERE cod_jogador = '$player'");
            $dest = mysql_fetch_row($qdest);
            $qmsgs = ownsql("SELECT COUNT(*) FROM mensagens WHERE emissor IN (SELECT nome FROM jogador WHERE cod_clan='$dest[1]') AND destinatario = '$dest[0]' AND lida=0");
        }
        //UPDATE DOS LOGS
        if($dados[1]!=1 && $dados[0]==1){
            $qdest = ownsql("SELECT nome FROM jogador WHERE cod_jogador = '$player'");
            $dest = mysql_fetch_row($qdest);
            $qlogs = ownsql("SELECT COUNT(*) FROM log WHERE receptor = '$dest[0]' AND lida=0");
        }
        //UPDATE DOS RANKINGS
        $qrank_nivel = ownsql("SELECT exp, cod_jogador FROM jogador WHERE acesso<>1 ORDER BY exp DESC");
        $i=1;
        while($rank = mysql_fetch_array($qrank_nivel)){
            if($rank[1]==$player){
                $ranking = $i.'º';
            }
            $i++;
        }
        if($row[1]!=0){
            $qrank_pvp = ownsql("SELECT pvp, cod_jogador FROM jogador WHERE acesso<>1 ORDER BY pvp DESC");
            $x=1;
            while($rank_pvp = mysql_fetch_array($qrank_pvp)){
                if($rank_pvp[1]==$player){
                    $pvp_rank = $x.'º';
                }
                $x++;
            }
        }else{
            $pvp_rank = "-";
        }
        if($row[0]!=0){
            $qrank_pk = ownsql("SELECT pk, cod_jogador FROM jogador WHERE acesso<>1 ORDER BY pk DESC");
            $z=1;
            while($rank_pk = mysql_fetch_array($qrank_pk)){
                if($rank_pk[1]==$player){
                    $pk_rank = $z.'º';
    }
                $z++;
            }
        }else{
            $pk_rank = "-";
        }
        if($row[3]!=0){
            $qrank_clan = ownsql("SELECT nivel,cod_clan FROM clans ORDER BY nivel DESC");
            $j=1;
            while($rank_clan = mysql_fetch_array($qrank_clan)){
                if($rank_clan[1]==$row[3]){
                    $clan_rank = $j.'º';
                }
                $j++;
            }
        }else{
            $clan_rank = "-";
        }
        $qcod_clan = ownsql("SELECT cod_clan FROM jogador WHERE cod_jogador = '$player'");
        $cod_clan = mysql_fetch_row($qcod_clan);
        if($cod_clan[0]!=0){
            $qtest_war = ownsql("SELECT cod_war, n_mortos FROM clans WHERE cod_clan = '$cod_clan[0]'"); //VER SE O CLAN ESTÁ EM GUERRA
            $test_war = mysql_fetch_row($qtest_war);
            if($test_war[0]!=0){ //está em guerra
                $qnome_war = ownsql("SELECT nome FROM clans WHERE cod_war = '$cod_clan[0]'");
                $nome_war = mysql_fetch_row($qnome_war);
                $adversario = $nome_war[0]; //nome do adversário
                $n_mortos = $test_war[1]; //numero de mortos
            }
        }
    
    ?>
    <html>
    <title>Be Eternal God</title>
    <head>
    <link type="text/css" rel="stylesheet" id="style">
    <?     echo "<script type=\"text/javascript\">document.getElementById(\"style\").href = \"css/".$skin."\";</script>"; ?>
    <script type="text/javascript">
    function startTime()
    {
    var today=new Date();
    var h=today.getHours();
    var m=today.getMinutes();
    var s=today.getSeconds();
    // add a zero in front of numbers<10
    m=checkTime(m);
    s=checkTime(s);
    document.getElementById('horas').innerHTML=h+":"+m+":"+s;
    t=setTimeout('startTime()',500);
    }
    
    function checkTime(i)
    {
    if (i<10)
      {
      i="0" + i;
      }
    return i;
    }
    </script>
    </head>
    <? 
    echo"<script type=\"text/javascript\">function online(){ online = 1; }</SCRIPT>";
    ?>
    <body vlink="#FFFFFF" alink="#FFFFFF" link="#FFFFFF" text="#FFFFFF" onload="startTime()">
    <table id='texto'>
                        <tr>
                            <td>
                                <div id="banner"></div>    
                            </td>
                        </tr>
    </table>
    <table id='texto' id="principal" width=985 border=1>
    <tr>
        <td width="200"  valign="top">
            <table id='texto' align="left" bgcolor="#000000" width="137">
            <tr>
                <td>
                    <div id="botao_menu">
                    </div>
                    <div id="texto">
                    <b><p>
                    <? echo $_SESSION['skin']."<br>";
        echo $_SESSION['cod']; ?><br>
                        <a href="home.php?inc=inicio.php&cod=<?php echo $player; ?>">Inicio</a><br>
                        <a href="home.php?inc=status.php&cod=<?php echo $player; ?>">Status</a><br>
                        <a href="home.php?inc=equip.php&cod=<?php echo $player; ?>">Equipamento</a><br>
                        <a href="home.php?inc=mochila.php&cod=<?php echo $player; ?>">Mochila</a><br>
                        <a href="home.php?inc=casa.php&cod=<?php echo $player; ?>">Território</a><br>
                        <br>
                        <a href="home.php?inc=cidade.php&cod=<?php echo $player; ?>">Cidade</a><br>
                        <a href="home.php?inc=clans.php&cod=<?php echo $player; ?>">Clans</a><br>
                        <a href="home.php?inc=teleport.php&cod=<?php echo $player; ?>">Teleport</a><br>
                        <br>
                            <a href="http://s10.invisionfree.com/Be_Eternal_God/" onClick="popup = window.open('http://s10.invisionfree.com/Be_Eternal_God/','PopupPage'); ">Forum</a><br>
                        <a href="php/conta.php?cod=<?php echo $player; ?>">Conta</a><br>
                        <a href="home.php?inc=ajuda.php&cod=<?php echo $player; ?>">Ajuda</a><br>
                        <a href="php/logout.php?cod=<?php echo $player; ?>">Log Out</a><br>
                        <?php
                            if($row[9]==1){
                                $link = "\"admin/index.php\"";
                            }
                            if($row[9]==2){
                                $link = "\"home.php?inc=administradores.php&cod=".$player."\"";
                            }
                        ?>
                        <a href= <?php echo $link; ?>>Administradores</a><br>
                    </p></b>
                    </div>
                    <div id="botao_down">
                    </div>
                </td>
            </tr>
        <tr>
            <td>
                <div id="botao_ranks">
                </div>
                    <table id='texto' border="0">
                        <tr>
                            <td><div id="texto"><b><?php echo "<a href=\"home.php?inc=rank_pk.php&cod=".$player."\">PK: </a>"; ?></b></div></td>
                            <td><div id="texto"><?php echo $pk_rank; ?></div></td>
                        </tr><tr>
                            <td><div id="texto"><b><?php echo "<a href=\"home.php?inc=rank_pvp.php&cod=".$player."\">PVP: </a>"; ?></b></div></td>
                            <td><div id="texto"><?php echo $pvp_rank; ?></div></td>
                        </tr><tr>
                        <td><div id="texto"><b><?php echo "<a href=\"home.php?inc=rank_jogadores.php&cod=".$player."\">Nível: </a>"; ?></b></div></td>
                            <td><div id="texto"><?php echo $ranking; ?></div></td>
                        </tr><tr>
                            <td><div id="texto"><b><?php echo "<a href=\"home.php?inc=rank_clans.php&cod=".$player."\">Clan: </a>"; ?></b></div></td>
                            <td><div id="texto"><?php echo $clan_rank; ?></div></td>
                        </tr>
                    </table>
                <div id="botao_down">
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <div id="botao_events">
                </div>
                <table id='texto'>
                    <tr>
                        <td><a href="home.php?inc=logs.php&cod=<?php echo $player; ?>"><div id="texto">Log: </div></a></td>
                        <td><div id="texto"><?php
                                    if(isset($qlogs)){
                                        $logs = mysql_fetch_row($qlogs);
                                        if ($logs[0] == 0){
                                            echo "[".$logs[0]."]";
                                        }else{
                                            echo "[<b>".$logs[0]."</b>]";
                                        }
                                    }else{
                                        echo "[0]";
                                    }
                                    ?></div></td>
                    </tr><tr>
                        <td><a href="home.php?inc=mensagens.php&cod=<?php echo $player; ?>"><div id="texto">Mensagens: </div></a></td>
                        <td><div id="texto"><?php
                                    if(isset($qmsgs)){
                                        $msgs = mysql_fetch_row($qmsgs);
                                        if ($msgs[0] == 0){
                                            echo "[".$msgs[0]."]";
                                        }else{
                                            echo "[<b>".$msgs[0]."</b>]";
                                        }
                                    }else{
                                        echo "[0]";
                                    }
                                    ?>
    
    
    
                                                    </div></td>
                    </tr><tr>
                        <td><a href="home.php?inc=contract.php&cod=<?php echo $player; ?>"><div id="texto">Contracto: </div></a></td>
                        <td><? 
                            $con = ownsql("SELECT contracto FROM jogador WHERE cod_jogador='$player'");
                            $con_row = mysql_fetch_row($con);
                            if ($con_row[0] == 1){
                                echo "<div id='texto'>[<b>ON</b>]</div>";
                            }else{
                                echo "<div id='texto'>[OFF]</div>";
                            }
                        ?></td>
                    </tr>
                </table>
                <div id="botao_downer">
                </div>
            </td>
        </tr>
    </table>
    </td>
    <td valign="top" bgcolor="#000000">
                <table id='texto' align="center" width="648">
                <tr>
                    <td>
                        <div id="centro"><?php
                                $included = $_GET['inc'];
                                $included = "php/game/".$included;
                                include($included);
                        ?>
                        </div>
                    </td>
                </tr>
                </table>
    </td>
    <?
        $result = ownsql("SELECT PK,PVP,nivel,cod_clan,nome,raca,HP_actual,job,dinheiro,acesso,status,zona, exp FROM jogador WHERE cod_jogador='$player'");
        $row = mysql_fetch_row($result);
    ?>
    <td valign="top">
    <table id='texto' align="right" bgcolor="#000000" width="137"  id="right">
        <tr>
            <td align="center">
                <div id="botao_mp3">
                </div>
                <a href="#" onClick="popup = window.open('php/functions/mp3.php','PopupPage','height=500,width=500,scroollbars=no,resizable=no'); "><b>Radio</b></a><br>
                             <div id="horas"></div>
                <div id="botao_down">
                </div>
            </td>
        </tr>
        <TR>
            <td>
                <div id="botao_mini_map">
                </div>
                <div id="texto">
                <p align="center">
                    <?
                     $cod_zona = $row[11];
                     include("php/functions/zona.php");
                     echo "<b>".$nome_zona."</b><br>";
                     echo "<center>".$nome_sitio."</center>";
                     ?>
                </p>
                </div>
                <div id="botao_down">
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <div id="botao_player">
                </div>
                <p>
                <?php
                    if(isset($adversario)){
                        echo "<center><font color=\"red\"><b>Estás em guerra com os ".$adversario.".</b></font><br>";
                        echo "<font color=\"red\"><b>Mortos:</b> ".$n_mortos."</font><center>";
                    }
                ?>
                <table id='texto'>
                    <tr>
                    <td><div id="texto"><b><?php if(isset($adversario)){ 
                                    echo "<font color=\"red\"><b>Nome:<b></font>";
                                     }else{
                                         echo "<b>Nome:</b>";
                                     }
                                ?></b></div></td>
                    <td><div id="texto"><?php
                                if(isset($adversario)){
                                    echo "<font color=\"red\">".$row[4]."</font>";
                                }else{
                                    echo $row[4];
                                }
                                ?></div></td>
                    </tr><tr>
                    <td><div id="texto"><b><?php if(isset($adversario)){ 
                                    echo "<font color=\"red\">Raça:</font>";
                                     }else{
                                         echo "Raça:";
                                     }
                                ?>
                            
                        </b></div></td>
                        <td><div id="texto"><?php
                                    if(isset($adversario)){
                                        echo "<font color=\"red\">".$row[5]."</font>";
                                    }else{
                                        echo $row[5];
                                    }
                                    ?></div></td>
                    </tr><tr>
                        <td><div id="texto"><b><?php if(isset($adversario)){ 
                                    echo "<font color=\"red\">Job:</font>";
                                     }else{
                                         echo "Job:";
                                     }
                                ?></b></div></td>
                                    <td><div id="texto"><?php
                                                if(isset($adversario)){ echo "<font color=\"red\">";
                                                }
                                                if(!isset($row[7])){
                                                echo "Nenhum";
                                                }else{
                                                      echo $row[7];
                                                }
                                                if(isset($adversario)){ echo "</font>";
                                                }
                                            ?></div></td>
                    </tr><tr>
                    <td><div id="texto"><b<?php 
                                    if(isset($adversario)){ 
                                        echo "<font color=\"red\"";
                                    }
                                    echo "<b>Nível: </b>";
                                    if(isset($adversario)){ echo "</font>"; }
    
                                ?></b></div></td>
                                    <td><div id="texto"><?php
                                                if(isset($adversario)){ echo "<font color=\"red\">"; }
                                                echo $row[2];
                                                if(isset($adversario)){ echo "</font>"; }
                                            ?></div></td>
                    </tr><tr>
    
                        <td><div id="texto"><b><?php if(isset($adversario)){ 
                                    echo "<font color=\"red\">Clan:</font>";
                                     }else{
                                         echo "Clan:";
                                     }
                                ?></b></div></td>
                                    <td><div id="texto"><?php
                                                if(isset($adversario)){ echo "<font color=\"red\">";
                                                }
                                                if($row[3]==0){
                                                        echo "Nenhum";
                                                }else{
                                                        $clanz = ownsql("SELECT nome FROM clans WHERE cod_clan='".$row[3]."'");
                                                        $clanz_row = mysql_fetch_array($clanz); 
                                                        echo $clanz_row[0];
                                                }
                                                if(isset($adversario)){ echo "</font>"; }
                                            ?></div></td>
                    </tr><tr>
                        <td><div id="texto"><b><?php if(isset($adversario)){ 
                                    echo "<font color=\"red\">Hp: </font>";
                                     }else{
                                         echo "Hp: ";
                                     }
                                ?></b></div></td>
                                    <td><div id="texto"><?php
                                            if(isset($adversario)){ echo "<font color=\"red\">"; }
                                                echo $row[6];
                                            
                                            if(isset($adversario)){ echo "</font>"; }
                                            ?></div></td>
                    </tr><tr>
                        <td><div id="texto"><b><?php if(isset($adversario)){ 
                                    echo "<font color=\"red\">Gold: </font>";
                                     }else{
                                         echo "Gold: ";
                                     }
                                ?></b></div></td>
                                    <td><div id="texto"><?php
                                            if(isset($adversario)){ echo "<font color=\"red\">"; }
                                            echo $row[8];
                                            if(isset($adversario)){    echo "</font>"; }                                    ?></div></td></tr><tr>
                                                <td><div id="texto"><b><?php
                                                if(isset($adversario)){
                                                    echo "<font color=\"red\">Exp Need: </font>";
                                                }else{
                                                    echo "Exp Need: ";
                                                }
                                            ?>
                                            </b></div></td>
                                            <td><div id="texto"><?php
                                            $exp_total = $row[2]*$row[2]*$row[2]*400;
                                            $exp_nec = $exp_total - $row[12];
                                            if(isset($adversario)){ echo "<font color=\"red\">"; }
                                            echo $exp_nec;
                                            if(isset($adversario)){ echo "</font>"; } ?></td>
                    </tr>
                </table>
                </p>
                </div>
                <div id="botao_downer">
                </div>
    <center><p><a href="home.php?inc=donate.php&cod=<?php echo $player; ?>"><img src="images/donate.jpg" alt="Help Us!" border="0"></a></p></center>
    <div id="botao_downer"></div><p>    
    <center><b>Autor:</b> Sasukez0r
    <b>Version:</b> 0.3<p>
    <i>Todos os direitos reservados &copy; 2008<i></center><p>
    <div id="botao_downer"></div>
    </td>
        </tr>
    </table>
    </td>
    </tr>
    </table>
    </body>
    </html>
    <?php
             $timestamp = time();
             if (!empty($_SERVER['HTTP_CLIENT_IP']))
    
      {
        $ip=$_SERVER['HTTP_CLIENT_IP'];
      }
      elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
      //to check ip is pass from proxy
      {
        $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
      }
      else
      {
        $ip=$_SERVER['REMOTE_ADDR'];
      }
    
    ownsql("UPDATE jogador SET ultima_accao = '$timestamp' ,ip = '$ip' WHERE cod_jogador = '$player'");                                        
    mysql_close();
    ?>
    
     
  6. Sa[n]dman

    Sa[n]dman Power Member

    o "session_start();" tem de ser a primeira linha de cada página, troca de posição o "session_start();" com o "ob_start();".

    Cumps
     
  7. Sasukez0r

    Sasukez0r Power Member

    antes não tinha o ob_start e dava o bug na mesma, e eu tenho outro jogo que fiz de naruto e o ob_start tá em primeiro e nao afecta em nada, mas vale a pena tentar obrigado pela tentativa ;D
     
  8. Sasukez0r

    Sasukez0r Power Member

  9. Sa[n]dman

    Sa[n]dman Power Member

    falta-te o php a seguir ao <? no inicio da segunda folha.

    Código:
    <?[COLOR="Red"]php[/COLOR]
        ob_start();
        session_start();
    
        ....
    
        mysql_close();
    ?>
    
    (Segunda vez esta semana :lol:)
     
  10. eralha

    eralha Power Member

    é dispensavel o php ..... na TAG
     
  11. Armadillo

    Armadillo Folding Member

    nem por isso...
    http://www.w3schools.com/PHP/php_syntax.asp
     
  12. Sa[n]dman

    Sa[n]dman Power Member

    Não é assim tão dispensável, tendo em conta que aqui resolveu a situação podes confirmar que é necessário por lá o php na TAG. Já foram tempos em que os browsers "comiam" qualquer coisa, agora querem tudo bem definido, e como bons programadores temos de o fazer. :)
     
  13. Sa[n]dman

    Sa[n]dman Power Member

    Última edição: 4 de Março de 2009
  14. Armadillo

    Armadillo Folding Member

    o browser nao interfere em nada. O <?php é apenas interpretado pelo servidor, e nao pelo browser.
     
  15. Sa[n]dman

    Sa[n]dman Power Member

    ok ok. Sorry, my mistake :sad:
     
  16. Sasukez0r

    Sasukez0r Power Member

    isso não resolveu, é indispensável apenas tentei por que não sei o que fazer mesmo =S
     
  17. geoblast

    geoblast Power Member

    Olá, não olhei para o código todo, mas esclarece o seguinte: estás a registar as variáveis de sessão?
     
  18. Sasukez0r

    Sasukez0r Power Member

    ja meti isse nao deu =S vou mandar o codigo again,

    loginvalidation.php
    PHP:
    <?php
    session_start
    ();
    ob_start();
    include(
    "functions/data_mysql.php");
    $link mysql_connect($server,$user,$pass,$bd);
     include(
    "functions/mysql.php");
    /*
     * Ficheiro responsável por todo o processo de validação de um
     * utilizador, encaminhando directamente para a pagina de
     * escolha/criação de personagens.
     */
    if(isset($_SESSION['cidade'])){
    $_SESSION['cidade'] = 0;
    }
    ?>
    <html>
    <title>Be Eternal God</title>
    <head>
    <link type="text/css" rel="stylesheet" id="style">
    <script>
        function disp_confirm(cod)
        {
            var name=confirm("Tens a certeza que dejesas apagar a personagem?")
        if (name==true){
            window.location="loginvalidation.php?d=" + cod        
        }
        else{
            window.location="loginvalidation.php"
        }
        }
    </script>
    </head>
    <body vlink="#FFFFFF" alink="#FFFFFF" link="#FFFFFF">
    <?php
    if($_GET['d']){
        
    $cod_del $_GET['d'];
        
            
    $stfu ownsql("SELECT n_mochila, n_casa FROM jogador WHERE cod_jogador='$cod_del'");
            
    $stuff mysql_fetch_array($stfu);
            
    ownsql("DELETE FROM mochila_itens WHERE n_mochila='$stuff[0]'");
            
    ownsql("DELETE FROM casa_itens WHERE n_casa='$stuff[1]'");
            
    ownsql("DELETE FROM casa WHERE cod_jogador='$cod_del'");
            
    ownsql("DELETE FROM mochila WHERE cod_jogador='$cod_del'");
            
    ownsql("DELETE FROM skillp_player WHERE cod_jogador='$cod_del'");
            
    ownsql("DELETE FROM skilla_player WHERE cod_jogador='$cod_del'");
            
    ownsql("DELETE FROM jogador WHERE cod_jogador='$cod_del'");

    }
        

    if (!isset (
    $_SESSION['user'])){
         if(
    $_POST['username']){
            
    $user $_POST['username'];
        }
        if(
    $_POST['pass']){
            
    $pass $_POST['pass'];
        }
     }else{
         
    $user $_SESSION['user'];
        
    $pass $_SESSION['pass'];
     }
     
    $result ownsql("SELECT login,password FROM conta WHERE login='$user' AND password='$pass'");
     
    $data mysql_fetch_row($result);
     
    $_SESSION['user']=$data[0];
     
    $_SESSION['pass']=$data[1]; 
     if(
    mysql_num_rows($result)==0){
     
             
    header ("Location: loginerror.php");
     }else{ 
    /*Login executado correctamente, Criação de novas personagens
             * ou escolha de uma jogável */
         
    if($_POST['skin']){
                
    $skin $_POST['skin'];
                
    $qskin ownsql("UPDATE conta SET skin = '$skin' WHERE login='$user'");
                
    $_SESSION['skin'] = $skin;
        }
        
    $qlol ownsql("SELECT cod_conta, skin FROM conta WHERE login='$user'");
         
    $lol mysql_fetch_array($qlol);
        
    session_register("_SESSION['cod']"); 
         
    $_SESSION['cod'] = $lol[0];
        
    session_register("_SESSION['skin']"); 
        
    $_SESSION['skin'] = $lol[1];
        echo 
    $lol[1];
        echo 
    $_SESSION['skin']."<br>";
        echo 
    $lol[0];
        echo 
    $_SESSION['cod'];
        echo 
    "<script type=\"text/javascript\">document.getElementById(\"style\").href = \"../css/".$lol[1]."\";</script>";
        echo 
    "<center><table id='texto' border=1 bgcolor=\"000000\">" .
              
    "<tr>" .
              
    "    <td>" .
              
    "        <table id='texto' border=0 border=0 width=\"468\">" .
              
    "            <tr>" .
              
    "                <td>" .
              
    "                        <div id=\"texto\">";
                                     
    $cod $_SESSION['cod'];
                                     
    $result ownsql("SELECT nivel,raca,dinheiro,img,nome,status,cod_jogador FROM jogador WHERE cod_conta='$cod'");
                                     echo 
    "<center><div id=\"botao_char\"></div></center>";
                                            while(
    $row mysql_fetch_array($result)){
                                                 echo 
    "<br><br><table id='texto' border=1 align=\"center\">";
                                                 if(
    $row[3]){ //se ouve imagem constroi a célula para ela
                                                     
    echo"<tr>" .
                                                         
    "    <td>" .
                                                         
    "        <img src = \"../images/chars/".$row[3]."\"></img>" .
                                                         
    "    </td>" .
                                                         
    "</tr>" ;                                             }
                                                    echo 
    "<tr>" .
                                                         
    "    <td>" .
                                                         
    "        <div id=\"texto\"><b>Nome: </div>" .
                                                         
    "    </td>" .
                                                         
    "    <td>" .
                                                         
    "            <div id=\"texto\">".$row[4]."</div>" .
                                                         
    "    </td>" .
                                                         
    "</tr>".
                                                         
    "<tr>" .
                                                         
    "    <td>" .
                                                         
    "        <div id=\"texto\"><b>Nível: </div>" .
                                                         
    "    </td>" .
                                                         
    "    <td>" .
                                                         
    "        <div id=\"texto\">".$row[0]."</div>" .
                                                         
    "    </td>" .
                                                         
    "</tr>" .
                                                         
    "<tr>" .
                                                         
    "    <td>" .
                                                         
    "        <div id=\"texto\"><b>Raca: </div>" .
                                                         
    "    </td>" .
                                                         
    "    <td>" .
                                                         
    "        <div id=\"texto\">".$row[1]."</div>" .
                                                         
    "    </td>" .
                                                         
    "</tr>" .
                                                         
    "<tr>" .
                                                         
    "    <td>" .
                                                         
    "        <div id=\"texto\"><b>Dinheiro: </div>" .
                                                         
    "    </td>" .
                                                         
    "    <td><div id=\"texto\">".$row[2]."</div>" .
                                                         
    "    </td>" .
                                                         
    "</tr>" .
                                                         
    "<tr>" .
                                                         
    "    <td>" .
                                                         
    "        <div id=\"texto\"><b>Status: </div>" .
                                                         
    "    </td>" .
                                                         
    "    <td>" .
                                                         
    "        ";
                                                                  if(
    $row[5]==1){ 
                                                                      echo 
    "<div id=\"texto\">Vivo</div>" .
                                                                                        
    "</td>" .
                                                                                        
    "</tr>" .
                                                                                        
    "</table>" .
                                                                                        
    "<center><br><a href=../home.php?inc=inicio.php&cod=".$row[6]."> Entrar </a> / ";
                            echo 
    "<a onclick=\"disp_confirm('".$row[6]."')\"> Apagar </a><br><hr></center>";
                                                                  }
                                                                 else{ 
                                                                     echo 
    "<div id=\"texto\">Morto</div>" .
                                                                          
    "    </td>" .
                                                                          
    "</tr>" .
                                                                          
    "</table><hr>";
                                                                     }
                                                     }
         echo 
    "                </td>" .
              
    "            </tr>" .
              
    "        </table>" .
              
    "    </td>" .
              
    "    <td align=\"right\" valign=\"top\"><br><br>" .
              
    "        <form method=\"POST\" name=\"newchar\" action=\"charvalidate.php\">" .
              
    "        <table id='texto' border=1 width=\"200\">" .
              
    "            <tr>" .
              
    "                <td><img src=\"../home_layout/botoes/new.jpg\"></td>" .
              
    "            </tr>" .
              
    "            <tr>" .
              
    "                <td><div id=\"texto\"><center><b>Nome: </b></center></div></td>" .
              
    "                <td><INPUT TYPE=\"text\" name=\"nome\"></td>" .
              
    "            </tr>" .
              
    "            <tr>".
             
    "            <td><center><input type=\"submit\" value=\"Criar\" /></center></td>" .
             
    "            </tr>" .
              
    "        </table></form>" .
             
    "      <a href=\"logout.php\"><div id=\"texto\"><center><b>Log Out</b></center><div></a>
                     <center><br><br><a href=\"loginvalidation.php?op=1\"><b>Opcções da Conta</b></a></center>"
    ;
            if(
    $_POST['new_pass']){
                if(
    $_POST['check_new_password']){
                    if(
    $_POST['check_new_password']==$_POST['new_pass']){
                        
    $pass $_POST['new_pass'];
                        
    $qpass ownsql("UPDATE conta SET password = '$pass' WHERE cod_conta = '$cod'");
                        echo 
    "<center><font color=\"green\"><b>Password Alterada</b></font></center>";
                        
    $_SESSION['pass'] = $pass;
                    }else{
                        echo 
    "<center><font color=\"red\"><b>As passwords não coincidem</b></font></center>";
                    }
                }else{
                    echo 
    "<center><font color=\"red\"><b>Não introduziu a password de verificação</b></font></center>";
                }
            }
            if(
    $_POST['new_email']){
                
    $email $_POST['new_mail'];
                if(
    strlen($email)>15){
                    echo 
    "<center><font color=\"red\"><b>O numero de caracteres do email ultrapassa o limite</b></font></center>";
                }else{
                        
    $qmail ownsql("UPDATE conta SET email = '$mail' WHERE cod_conta='$cod'");
                        echo 
    "<center><font color=\"green\"><b>O email foi actualizado</b></font></center>";
                    }
            }
            if(
    $_POST['skin']){
                
    $skin $_POST['skin'];
                
    $qskin ownsql("UPDATE conta SET skin = '$skin' WHERE cod_conta='$cod'");
                
    $_SESSION['skin'] = $skin;
                echo 
    "<center><font color=\"green\"><b>A Skin foi alterada </b></font></center>";
            }
            if(
    $_GET['op']){
                echo 
    "<form method=\"post\" action=\"loginvalidation.php\" name=\"alteracoes\">";
                echo 
    "<br><hr><center>
                        <table id='texto'>
                            <tr>
                                <td><div id=\"texto\">Nova Password: </div></td><td><input type=\"password\" name=\"new_pass\"></td>
                            </tr>
                            <tr>
                                <td><div id=\"texto\">Confirmar Nova Password: </div></td><td><input type=\"password\" name=\"check_new_password\"></td>
                            </tr>
                            <tr>
                                <td><div id=\"texto\">Novo Email: </div></td><td><input type=\"text\" name=\"new_email\"></td>
                            </tr>"
    ;
                            echo 
    "<tr><td><div id=\"texto\">Temas: </div></td><td><select name=\"skin\">";
                            if (
    $handle opendir('../css')) {
                                while (
    false !== ($file readdir($handle))) {
                                    if (
    $file != "." && $file != "..") {
                                        echo 
    "<option value=\"".$file."\">".$file;
                                    }
                                }
                                
    closedir($handle);
                            }

                            echo 
    "</select></td></tr></table>";
                            echo 
    "<input type=\"submit\" name=\"alt\" value=\"Enviar\">
                                  &nbsp;&nbsp; / &nbsp;&nbsp;
                                  <input type=\"reset\" value=\"Limpar\">"
    ;
            }
            echo 
    "</td></tr></table>";
    }
    ?>
    <?
    mysql_close();
    ?>
    </body>
    </html>
     

Partilhar esta Página