|
||||||
Views:
14,875,633 |
![]() ![]() ![]() ![]() |
08-23-25 10:14 PM |
||||
Guest: Register | Login |
0 users currently in msg db 'Computer Address',0xa | 5 guests | 1 bot |
Main - msg db 'Computer Address',0xa - php struggles |
Jamie |
| ||
Banned
Excessive drama. Level: 74 ![]() ![]() ![]() ![]() Posts: 1137/1480 EXP: 3645349 Next: 8195 Since: 06-03-14 Last post: 2333 days Last view: 1016 days |
basically trying to write a script that fetches a page and then displays its contents, using the URL param "page" after "index.php" or whatever i.e. something like ABXD's index.php currently unfinished. it DOES seem to do its job somewhat: having some trouble with stuff tho. I'm unable to make a 404 fallback, for a start. plus I feel this is inefficient as hell. as a new coder, I'm probably making basic mistakes :p also none of this was copypasted from ABXD, even though I used the same setup and variable names as it. i'm actually trying to write a small PHP blog script ![]() any suggestions? ____________________ Good riddance! |
Epele |
| ||
Site Administrator
The Sorceress. Boing~ Level: 239 ![]() ![]() ![]() ![]() Posts: 18619/20774 EXP: 211361627 Next: 2798860 Since: 01-01-12 From: UK Last post: 1327 days Last view: 7 hours |
Let's see..
using file_get_contents() will pull the exact contents of the file. It will not render that page as php, but print the entire source code.. Consider using Include instead and letting the page print its own output. I believe you can also use include in an if() statement for error reporting - 404s. Personally, I've not had a need to use include statements yet. Gonna go test that theory out. Editorial: I've just played with it.
Include statements must be encapsulated in brackets inside an if() statement. In the case of this, it will include index.php which prints its own output normally, so it displays as part of the page. file_get_contents is more useful when you are dealing with stored files, such as caches, or doing operations on a binary file. Personally, I'm not a fan of breaking in and out of php, and prefer to do the entire operation in one go. If I need to inject a piece of php in the middle of a print, I'd do it like:
The world could always use more heroes! |
Moonlight Capital |
| ||
Normal User
Click here for catgirls Level: 33 ![]() ![]() ![]() ![]() Posts: 233/243 EXP: 221077 Next: 8102 Since: 04-26-16 From: Italy Last post: 2407 days Last view: 2407 days |
This is my page rendering handler:
Though you need a .htaccess rule to achieve this, see https://stackoverflow.com/a/51362256/7486110 |
Arisotura |
| ||
Developer
pancakes Level: 85 ![]() ![]() ![]() ![]() Posts: 1601/1873 EXP: 5719898 Next: 178642 Since: 01-05-12 From: France Last post: 90 days Last view: 33 days |
you don't seem to really know what XSS is...
also, while you're at it with .htaccess-level URL rewriting, might as well just rewrite it to page.php?shit=foo&crap=bar so there's less overhead on the PHP side (you don't have to do decoding/etc there). but whatever, this works too. ____________________ Kuribo64 - melonDS want some revolution in your coffee? |
Moonlight Capital |
| ||
Normal User
Click here for catgirls Level: 33 ![]() ![]() ![]() ![]() Posts: 234/243 EXP: 221077 Next: 8102 Since: 04-26-16 From: Italy Last post: 2407 days Last view: 2407 days |
Posted by StapleButter I used to do it that way, but url rewriting was hard if you had parameters with different names. |
Main - msg db 'Computer Address',0xa - php struggles |
Acmlmboard v2.5.6 (06/11/2024) © 2005-2025 Acmlm, Emuz, et al. |
MySQL - queries: 95, rows: 516/549, time: 1.538 seconds. |