Dúvida PHP - Iframes

pedro-silva

Power Member
Boas,
tenho aqui uma duvida com um código:

Código:
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->

  <tr>
    <td width="100%" height="300">
    <iframe
    name="menu" 
    src ="menu.php"
    width="100%"
    height="300"
    frameborder="0"
    scrolling="no"
    TARGET="centro"
    >
    </iframe></td>
  </tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="100%" height="555">

    <iframe 
    name="centro" 
    id="centro"
    src ="<? $_GET['id'] ?>"
    width="100%"
    height="555"
    frameborder="0"
    scrolling="no"
    onload=resize_iframe();
    ><span class="style1"></span>    </iframe></td>
  </tr>
</table>
  <table width="100%" border="0" cellpadding="0" cellspacing="0" height="80" background="images/rep_2.jpg">

  <tr>
    <td width="100%" height="80"> <div align="center" class="style1"> <strong>Copyright &copy; 2008 OnlyPT.com.com</strong> - Serviços de Internet</div></td>

  </tr>
</table>
</body>
a minha duvida tá na linha: src ="<? $_GET['id'] ?>"

o que eu pretendia era ter um site com iframes. mas pode mudar o conteudo do main pelo link.
por exemplo: www.meusite.com\index.php?id=pagina2.php

é possivel ?

Cumps
 
claro. podes ter por exemplo vários links com estes destinos por exemplo:

index.php?id=pagina1.php
index.php?id=pagina2.php
index.php?id=pagina3.php
 
já consegui !
fiz:

Código:
<?php
$query = $_GET['id'];
if ($query==NULL){
$url="main.html";
}
else {
$url = $query;
}
?>
...
...

Código:
 src ="<?php echo $url; ?>"
 
Isso do $url=$query

não é grande ideia do ponto de vista da segurança.
Assim estás a dar acesso a todos os ficheiros que estejam no servidor.

Devias pelo menos usar um switch, tipo:

Código:
switch ($query) {

    case "pagina1":
        $url=pagina1.php;
        break;
    case "pagina2":
        $url=pagina2.php;
        break;
    case "pagina3":
        $url=pagina3.php;
        break;
    default:
        $url=main.html;    
        break;

}

e assim limitas os ficheiros aos quais é possível aceder.
 
Back
Topo