Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Problem ze skrytpem zmieniającym skórkę...
Forum PHP.pl > Forum > Przedszkole
vieri_pl
Witam mam następujący problem. MAm skrypt który ma mi zmieniać skórkę...
Ale jak zmieniam to nie działa jest w parametrze linka index.php?set_theme=drugi ale nie działa ! Podejrzewam że to wina register_globals_off, oto kod:

  1. <?
  2. $default_theme = 'default';
  3. function set_theme() {
  4.  
  5. global $set_theme, $logs, $theme, $default_theme;
  6.  
  7.  
  8. if($set_theme<>'') {
  9. $theme = $_GET['set_theme'];
  10. if(file_exists("theme/$set_theme")) {
  11. $theme = $set_theme;
  12. $czas = mktime(0,0,0,date("m"),date("d"),date("Y")+5);
  13. setcookie("theme", $set_theme, $czas);
  14. header("Location: index.php");
  15. }
  16. }
  17.  
  18. if($theme=='' OR !file_exists("theme/$theme")) {
  19.  
  20. $theme = $default_theme;
  21.  
  22. } else {
  23.  
  24. if(!file_exists("theme/$set_theme"))
  25. $theme = $default_theme;
  26. }
  27. }
  28.  
  29. function stheme_form() {
  30.  
  31.  
  32. global $theme;
  33.  
  34. echo '<center><form></FORM><select name="set_theme" OnChange="selecturl(this)">';
  35.  
  36.  
  37. $dir = opendir("theme");
  38.  
  39. while($r = readdir($dir)) {
  40.  
  41. if($r<>'.' AND $r<>'..' AND is_dir('theme/'.$r)) {
  42.  
  43. if($r==$theme) $napis = ' selected'; else $napis ='';
  44.  
  45. $v = 'index.php?set_theme='.$r;
  46.  
  47. echo '<option value="'.$v.'"'.$napis.'>'.$r.'</option>';
  48.  
  49. }
  50. }
  51.  
  52. echo '</select></form></center>';
  53.  
  54.  
  55.  
  56. }
  57. error_reporting( E_ALL );
  58. ini_set( 'display_errors', 1 );
  59. //nclude('functions/globals.php');
  60.  
  61.  
  62.  
  63. require_once('functions/engine.php');
  64. set_theme();
  65. $upage_title = "Witam";
  66. $t_folder = 'theme';
  67.  
  68.  
  69. //require('functions/mysql.php');
  70. //include('functions/news.php');
  71. //include("grafika/styl.php");
  72. # Elementy szkieletu strony
  73. include_once(''.$t_folder.'/'.$theme.'/header.php');
  74. include_once(''.$t_folder.'/'.$theme.'/left.php');
  75. include_once(''.$t_folder.'/'.$theme.'/right.php');
  76. # Treść strony
  77. include_once(''.$t_folder.'/'.$theme.'/content.php');
  78. # Stopka
  79. include_once(''.$t_folder.'/'.$theme.'/footer.php');
  80. ?>


Można ten błąd zobaczyć:
kportal.goin.pl

Formularz zmieniania jest w prawym dolnym rogu strony smile.gif
nospor
  1. <?php
  2. global $set_theme, $logs, $theme, $default_theme;
  3. if($set_theme<>'') {
  4. $theme = $_GET['set_theme'];
  5. //.....
  6. ?>
blink.gif
po co globalizujesz zmienną ze ztablicy suoerglobalnej $_GET, ktora jest wszedzie dostępna?

powinno byc:
  1. <?php
  2.  
  3. global $logs, $theme, $default_theme;
  4. if(isset($_GET['set_theme']) && $_GET['set_theme']!='') {
  5. $theme = $_GET['set_theme'];
  6. //.....
  7.  
  8. ?>


chyba ze ja czegos nie zalapalem w Twojej logice. jesli tak - to mnie popraw
dtb
@nospor:
isset($_GET['set_theme']) && $_GET['set_theme']!=''
od tego jest funkcja empty" title="Zobacz w manualu php" target="_manual
nospor
w tym przypadku masz racje. krociej jest stosowac empty.
Ale ja stosuje to moje rozwiązanie z przyzwyczajenia. A czemu? Gdyz empty() zwroci rownież true, jesli zmienna ma wartość 0. a to nie zawsze jest prawda smile.gif.
vieri_pl
No zamieniłem tak jak napisłaes nospor ale i tak nie działa, najdziwniejsze jest to że tam gdzie mam przekierowanie do index.php nie przenosimnie tam ! Dlaczego questionmark.gif

Jeżeli zamiast isset dam empty również nie działa... a gdy mam isset na localhoscie u mnie w domu. gdzie register_globals mam na on wszystko jest ok, no ale tam gdzie register_globals jest off nie dizła

Oto cały mój kod:

plik index.php:

  1. <?php
  2.  
  3. require_once('functions/engine.php');
  4. $default_theme = 'default';
  5. set_theme();
  6. error_reporting( E_ALL );
  7. ini_set( 'display_errors', 1 );
  8. $upage_title = "Witam";
  9. $t_folder = 'theme';
  10.  
  11. //require('functions/mysql.php');
  12. //include('functions/news.php');
  13. //include("grafika/styl.php");
  14. # Elementy szkieletu strony
  15. include_once(''.$t_folder.'/'.$theme.'/header.php');
  16. include_once(''.$t_folder.'/'.$theme.'/left.php');
  17. include_once(''.$t_folder.'/'.$theme.'/right.php');
  18. # Treść strony
  19. include_once(''.$t_folder.'/'.$theme.'/content.php');
  20. # Stopka
  21. include_once(''.$t_folder.'/'.$theme.'/footer.php');
  22.  
  23.  
  24. ?>


plik engine.php:

  1. <?php
  2. // Uzytkownik do bazy danych
  3. define('DB_USER', 'root'); 
  4.  
  5. // Hasło do bazy danych
  6. define('DB_PASSWORD', ''); 
  7.  
  8. // Adres do bazy danych
  9. define('DB_HOST', 'localhost');
  10.  
  11. // Nazwa bazy danych
  12. define('DB_NAME', 'kportal_goin_pl');
  13.  
  14. // Łączenie do bazy MySQL
  15. //$dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) or DIE ('Nie udało się połączyć z bazą danych <BR>' . mysql_error());
  16.  
  17. // Wybieranie bazy danych
  18. //mysql_select_db (DB_NAME) or DIE ('Nie udało się wybrać bazy danych <BR>' . mysql_error());
  19.  
  20. // Tytuł strony
  21. $page_title = 'KPortal - strona domowa Krystiana Podemskiego';
  22.  
  23. // Słowa kluczowe strony
  24. $keywords = "Strona domowa, Krystian Podemski, Vieri, php, mysql, programowanie, skrypty
    , tutoriale, o mnie"
    ;
  25.  
  26. // Opis strony
  27. $description = "Strona domowa - Krystiana Podemskiego";
  28.  
  29.  
  30. function set_theme() {
  31.  
  32. global $set_theme, $logs, $theme, $default_theme;
  33.  
  34.  
  35. if(isset($_GET['set_theme']) && $_GET['set_theme']!='') {
  36. $theme = $_GET['set_theme'];
  37. if(file_exists("theme/$set_theme")) {
  38. $theme = $set_theme;
  39. $czas = mktime(0,0,0,date("m"),date("d"),date("Y")+5);
  40. setcookie("theme", $set_theme, $czas);
  41. header("Location: index.php");
  42. }
  43. }
  44.  
  45.  
  46. if($theme=='' OR !file_exists("theme/$theme")) {
  47.  
  48. $theme = $default_theme;
  49.  
  50. } else {
  51.  
  52. if(!file_exists("theme/$set_theme"))
  53. $theme = $default_theme;
  54. }
  55. }
  56.  
  57. function stheme_form() {
  58.  
  59.  
  60. global $theme;
  61.  
  62. echo '<center><form></FORM><select name="set_theme" OnChange="selecturl(this)">';
  63.  
  64.  
  65. $dir = opendir("theme");
  66.  
  67. while($r = readdir($dir)) {
  68.  
  69. if($r<>'.' AND $r<>'..' AND is_dir('theme/'.$r)) {
  70.  
  71. if($r==$theme) $napis = ' selected'; else $napis ='';
  72.  
  73. $v = 'index.php?set_theme='.$r;
  74.  
  75. echo '<option value="'.$v.'"'.$napis.'>'.$r.'</option>';
  76.  
  77. }
  78. }
  79.  
  80. echo '</select></form></center>';
  81.  
  82.  
  83.  
  84. }
  85.  
  86. ?>


No np. plik header.php:

  1. echo'
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
  6. <title>'.$page_title.' - '.$upage_title.'</title>
  7. <meta name="description" content="'.$description.'">
  8. <meta name="keywords" content="'.$keywords.'">
  9. <link rel="stylesheet" type="text/css" href="'.$t_folder.'/'.$theme.'/styl.css" />
  10. ';
  11. ?>
  12. <!-- (C) 2004 stat.pl - ver 1.0 / Strona glowna witryny -->
  13. <script type="text/javascript">
  14. document.writeln('<'+'scr'+'ipt type="text/javascript" src="http://s4.hit.stat.pl/_'+(new Date()).getTime()+'/script.js?id=bVnldEuu0Rw6SNPFSNWlEsbiTBLwdZCJqYo3E78s1Aj.87/l=11"></'+'scr'+'ipt>');
  15. </script>
  16. <script LANGUAGE="JavaScript">
  17. function selecturl(s) {
  18. var gourl = s.options[s.selectedIndex].value; window.top.location.href = gourl;
  19. }
  20. </SCRIPT>
  21. </head>
  22. <body>
  23. <div id="zawartosc">
  24. <div id="naglowek">
  25. <?
  26. <img src="'.$t_folder.'/'.$theme.'/grafika/logo.jpg" alt="Strona domowa Krystiana Podemskiego" width="870" height="150" /></div>
  27. ';
nospor
bo przekierowanie robisz warunkowo. jesli istnieje plik: "theme/$set_theme" to wtedy przkierowanie. najwyraźniej nie istnieje smile.gif
daj se echo "d..a"; w warunku i zobacz czy oby napewni ci tam wszedł 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.