Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: jak zmienic includowanie
Forum PHP.pl > Forum > PHP
marezo
  1. <html>
  2. <head>
  3.  
  4.  
  5.  
  6. <title>HURTOWNIA WARZYW I OWOCÓW</title>
  7.  
  8. <link href="style.css" rel="stylesheet" type="text/css">
  9. <meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
  10. </head>
  11. <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
  12.  
  13. <center><table id="Table_01" width="778" height="801" border="0" cellpadding="0" cellspacing="0">
  14. <tr>
  15. <td colspan="2" rowspan="2">
  16. <img src="images/index_01.jpg" width="51" height="292" alt=""></td>
  17. <td colspan="5">
  18. <img src="images/index_02.jpg" width="246" height="153" alt=""></td>
  19. <td colspan="3">
  20. <img src="images/index_03.jpg" width="429" height="153" alt=""></td>
  21. <td colspan="2" rowspan="2">
  22. <img src="images/index_04.jpg" width="52" height="292" alt=""></td>
  23. </tr>
  24. <tr>
  25. <td colspan="8">
  26. <img src="images/index_05.jpg" width="675" height="139" alt=""></td>
  27. </tr>
  28. <tr>
  29. <td colspan="3">
  30. <img src="images/index_06.jpg" width="87" height="62" alt=""></td>
  31. <td>
  32. <a href="index.php?s=firma"><img src="images/index_07.jpg" width="72" height="62" alt="" border="0"></td>
  33. <td colspan="2">
  34. <a href="index.php?s=oferta"><img src="images/index_08.jpg" width="105" height="62" alt="" border="0"></td>
  35. <td colspan="2">
  36. <a href="index.php?s=kontakt"><img src="images/index_09.jpg" width="103" height="62" border="0"></td>
  37. <td>
  38. <img src="images/index_10.jpg" width="155" height="62" alt=""></td>
  39. <td colspan="3">
  40. <img src="images/index_11.jpg" width="256" height="62" alt=""></td>
  41. </tr>
  42. <tr>
  43. <td>
  44. <img src="images/index_12.jpg" width="12" height="385" alt=""></td>
  45. <td colspan="4">
  46. <img src="images/index_13.jpg" width="213" height="385" alt=""></td>
  47. <td colspan="6">
  48. <?php
  49. if(empty($_GET['s'])) include"firma.php"; else include $_GET['s'].'.php';
  50. ?></td>
  51.  
  52. <td>
  53. <img src="images/index_15.jpg" width="22" height="385" alt=""></td>
  54. </tr>
  55. <tr>
  56. <td colspan="12">
  57. <img src="images/index_16.jpg" width="778" height="19" alt=""></td>
  58. </tr>
  59. <tr>
  60. <td colspan="12">
  61. <img src="images/index_17.jpg" width="778" height="42" alt=""></td>
  62. </tr>
  63. <tr>
  64. <td>
  65. <img src="images/spacer.gif" width="12" height="1" alt=""></td>
  66. <td>
  67. <img src="images/spacer.gif" width="39" height="1" alt=""></td>
  68. <td>
  69. <img src="images/spacer.gif" width="36" height="1" alt=""></td>
  70. <td>
  71. <img src="images/spacer.gif" width="72" height="1" alt=""></td>
  72. <td>
  73. <img src="images/spacer.gif" width="66" height="1" alt=""></td>
  74. <td>
  75. <img src="images/spacer.gif" width="39" height="1" alt=""></td>
  76. <td>
  77. <img src="images/spacer.gif" width="33" height="1" alt=""></td>
  78. <td>
  79. <img src="images/spacer.gif" width="70" height="1" alt=""></td>
  80. <td>
  81. <img src="images/spacer.gif" width="155" height="1" alt=""></td>
  82. <td>
  83. <img src="images/spacer.gif" width="204" height="1" alt=""></td>
  84. <td>
  85. <img src="images/spacer.gif" width="30" height="1" alt=""></td>
  86. <td>
  87. <img src="images/spacer.gif" width="22" height="1" alt=""></td>
  88. </tr>
  89. </table>
  90. <!-- End ImageReady Slices -->
  91. </body>
  92. </html>



cos jest nie tak z tym kodem. Niby wszystko działa ale ostatnio znajmy mówił żebym poprawił ten kod (includowanie)

l0ud
To poważna dziura bezpieczeństwa, dlatego usuń link z forum - nie jest on potrzebny do rozwiązania problemu, a tak zaraz strona może przestać istnieć.
marezo
juz smile.gif jak teraz to zmienic. questionmark.gif
nowotny
W pasku adresu daj sobie index.php?s=http://wp.pl/index i zobaczysz dlaczego jest to niebezpieczne...

Widzę że masz raptem 3 podstrony... w tym wypadku najlepiej zapisać sobie ich nazwy w tablicy i sprawdzać czy zawartość zmiennej $_GET['s'] znajduje się w tej tablicy...
l0ud
Ok, oto jak najprościej to poprawić:

zamień

  1. <?php
  2. if(empty($_GET['s'])) include"firma.php"; else include $_GET['s'].'.php';
  3. ?>


na

  1. <?php
  2. if(empty($_GET['s'])) include('firma.php');
  3. else {
  4. if ($_GET['s'] == 'oferta') include('oferta.php');
  5. else if ($_GET['s'] == 'kontakt') include('kontakt.php');
  6. else include('firma.php');
  7. }
  8. ?>


czyli po prostu przewidujemy wszystkie możliwości i dołączamy odpowiednie podstrony
marezo
dzieki wielkie:)



  1. <?php
  2. if(empty($_GET['s'])) include('firma.php');
  3. else {
  4. if ($_GET['s'] == 'oferta') include('oferta.php');
  5. else if ($_GET['s'] == 'kontakt') include('kontakt.php');
  6. else include('firma.php');
  7. }
  8. ?>



a jak bym do tego chcial wiecej podstron dac to jak??
wizu
W tym wypadku lepsze będzie switch

  1. <?php
  2. switch ($_GET['s']) {
  3. case ' oferta': 
  4. include('oferta.php');
  5. break;
  6. case 'praca': 
  7.  include('praca.php');
  8.  break;
  9. case 'x': 
  10. include('x.php');
  11. break;
  12. default:
  13. include('firma.php');
  14. break;
  15. }
  16. ?>
tomko222
Switch będzie lepsze ale można też dodać kolejne else if:

  1. <?php
  2. if(empty($_GET['s'])) include('firma.php');
  3. else {
  4. if ($_GET['s'] == 'oferta') include('oferta.php');
  5. else if ($_GET['s'] == 'kontakt') include('kontakt.php');
  6. else if ($_GET['s'] == 'aaaaa') include('aaaaa.php');
  7. else if ($_GET['s'] == 'bbbbb') include('bbbbb.php');
  8. else include('firma.php');
  9. }
  10. ?>


smile.gif
nowotny
A ja nadal twierdzę że najlepsza będzie tablica... tongue.gif dopisujemy jeden element i finito... nie trzeba kombinować z kolejnymi caseami czy elseifami... smile.gif
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.