[PHP] File includen werkt niet

Gestart doorRunelabe8 reacties39 weergaven

9 berichten · pagina 1 van 1

Runelabe

Lid · Topicstarter

Berichten
602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb de volgende PHP code:

[COLOR= #0000BB]<?php[/COLOR]
                [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]p[/COLOR][COLOR= #007700]])) {[/COLOR]
                    [URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]home.php[/COLOR][COLOR= #007700];
                }[/COLOR] [URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]p[/COLOR][COLOR= #007700]]==[/COLOR] home[COLOR= #007700]) {[/COLOR]
                    [URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]home.php[/COLOR][COLOR= #007700];
                }[/COLOR] [URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/file_exists"]file_exists[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]p[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000].php[/COLOR][COLOR= #007700])) {[/COLOR]
                    [URL="http://www.php.net/include"]include[/URL] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]p[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000].php[/COLOR][COLOR= #007700];
                }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
                    [URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]prog.php?p=[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]p[/COLOR][COLOR= #007700]];
                }[/COLOR]
        ?>


En als ik ga naar DOMEIN.NL/csi ga, dan krijg ik deze errors:

Warning: include(prog.php?p=CSI) [function.include]: failed to open stream: No such file or directory in /home/hftmaeyc/domains/tvfan.be/public_html/content.php on line 9

Warning: include(prog.php?p=CSI) [function.include]: failed to open stream: No such file or directory in /home/hftmaeyc/domains/tvfan.be/public_html/content.php on line 9

Warning: include() [function.include]: Failed opening prog.php?p=CSI for inclusion (include_path=.:/usr/local/lib/php) in /home/hftmaeyc/domains/tvfan.be/public_html/content.php on line 9


Er is geen pagina csi.php maar dan word ie dus doorgestuurd naar prog.php?p=csi. Maar die pagina kan hij niet vinden.
Het gekke hieraan is, als ik naar DOMEIN.NL/prog.php?p=csi ga, dan krijg ik die pagina gewoon...
Voor als het bruikbaar zou zijn, prog.php heeft de volgende code:

[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/include_once"]include_once[/URL][COLOR= #DD0000]config.inc.php[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$prog[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]p[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #FF8000]// Get all the data from the "example" table[/COLOR]
[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM *WEGGELATEN* WHERE naam="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$prog[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] 
or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]  

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<table border=1>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<tr> <th>Naam</th> <th>Leden</th> </tr>"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #FF8000]// keeps getting the next row until there are no more to get[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR] [COLOR= #0000BB]$result[/COLOR] [COLOR= #007700])) {[/COLOR]
    [COLOR= #FF8000]// Print out the contents of each row into a table[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<tr><td>"[/COLOR][COLOR= #007700];[/COLOR] 
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</td><td>"[/COLOR][COLOR= #007700];[/COLOR] 
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]leden[/COLOR][COLOR= #007700]];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</td></tr>"[/COLOR][COLOR= #007700]; 
}[/COLOR] 

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</table>"[/COLOR][COLOR= #007700];[/COLOR]
?>


Even in eht kort: Prog.php werkt wel als je m gewoon bezoekt, maar nietmeer als hij geincluded is...

Weet iemand wat hieraan te doen valt??
0
Berichten
153
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oké, eerst zie ik een leuke gevaarlijke beveiligingslek: "include $_GET[p]..php;",
Je kan gewoon ../BESTANDJE en je hebt b.v. bestand van je server te pakken emo.

Is er ook een content.php? Want daar geeft die de fout op lijn 9. emo
0
Runelabe

Lid · Topicstarter

Berichten
602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Goldo schreef:
Oké, eerst zie ik een leuke gevaarlijke beveiligingslek: "include $_GET[p]..php;",
Je kan gewoon ../BESTANDJE en je hebt b.v. bestand van je server te pakken emo.

Is er ook een content.php? Want daar geeft die de fout op lijn 9. emo
Het eerste is opzich geen beveiligingselk aangezien ik geen externe bestanden kan includen. Verder is content.php de bovenste code, lijn negen is

include prog.php?p=.$_GET[p];


En doe ik niet gewoon ../bESTANDJE want ik wil schone urls wink
Indien mijn HTACCES handig zou zijn:

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} libwww [NC,OR]

RewriteCond %{QUERY_STRING} ^(.*)=http [NC]

RewriteRule ^(.*)$  [F,L]

# BESTAANDE MAPPEN
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.* - [L]

# NIET BESTAANDE MAPPEN
RewriteRule ^([^/.]+)/([^/.]+)/?$ index.php?p=$1&sp=$2 [L]
RewriteRule ^([^/.]+)/?$ index.php?p=$1 [L]
RewriteRule ^([^/.]+)?$ index.php?p=$1 [L]
0
Berichten
8.602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Includen kan niet met ?p=
0
Berichten
3.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Milan schreef:
Includen kan niet met ?p=
Jawel?

Staan die bestanden wel in de public_html, en dan bedoel ik het include bestand én de te includen bestanden. Welk bestand staat waar?
0
Berichten
8.602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
JE KAN NIET include(hoi.php?get=sdfd); ALLEEN include(hoi.php);
0
Berichten
153
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Je kan wel:

Index.php

[COLOR= #0000BB]<?php $test[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"Hoi!"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]bestand.php[/COLOR][COLOR= #007700]);[/COLOR] ?>


Bestand.php

[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$test[/COLOR][COLOR= #007700];[/COLOR] ?>


Dacht ik wink
0
Berichten
3.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oh, dat bedoel je yummie Had ik niet gezien
0
Runelabe

Lid · Topicstarter

Berichten
602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oke, bedankt...
Goed dat ik dat weet smile
Edit: Werkt nu smile
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren