vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Can you php include a dynamic link? (https://vborg.vbsupport.ru/showthread.php?t=250785)

BigJohnny 09-19-2010 01:34 AM

Can you php include a dynamic link?
 
quick question, can you php include a dynamic link like

PHP Code:

<?php include("index.php?do=something"); ?>


kh99 09-19-2010 12:48 PM

Hmm...well, you can request a remote file in various ways (in which case it could be local or remote). Here's a page that describes this: http://www.php-mysql-tutorial.com/wi...using-php.aspx , but I'm guessing that's not what you want since you'd want the external script to execute like it was called by the user that requested *your* page.

You can include a file but it will be executed and will send out an entire HTML page as a result, and that's probably not what you want. [S]And you can't put "?do=something" on it.[/S] (ETA: I was wrong - see later comment)

You could probably adjust the global variables then include a script and capture the output like this:

Code:

$_REQUEST['do'] = 'something'
ob_start();
include('index.php');
$includedphp = ob_get_contents();
ob_end_clean();

but then you'd probably have to do some processing of the resulting string to get what you want.

BigJohnny 09-19-2010 02:41 PM

heres why I ask, I have a htaccess "mod" that hides robots.txt from everyone but the big 3 robots.

part of this is adding the MIME type to treat the txt as a php file, and at the beginning of robots.txt Ive added the line
Code:

<?php include("index.php?do=something"); ?>
then I've put the "something" call in my index.php file (non vB index)

it appears to work, and when I try and load the robots.txt file in my browser I'm thrown back to the main index......working as it should.

I'm really wondering if the include is loading the entire index.php file, or if it really is just loading that little piece of code to do the bot check.

kh99 09-19-2010 02:53 PM

Well, you know...I just never thought of that, but I was wrong - you *can* put a url in an include statement. I guess I don't know exactly what's going on in your situation.

BigJohnny 09-19-2010 04:52 PM

I didn't want to mention what I was doing in case I "tainted" the responses.

Anyway long story short, It was a shot in the dark and I didn't think it would work, but it does, I just want to know why and/or if I'm doing it right or if it's one of those things that will work but isn't right.

I didn't know a PHP INCLUDE could call a dynamic URL. instead of loading index.php, it seems to actually only call "?do=" code because it works exactly as it should from the human end.

I won't know if it fully works until I open my site and the bots start trying to crawl.

kh99 09-19-2010 05:22 PM

Yeah, well, I'm not a PHP or vBulletin expert, but there seems to be people here who aren't really programmers who could use a little help. Unfortunately I sometimes embarrass myself by "helping" people who actually know more about this than I do.


All times are GMT. The time now is 04:42 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00967 seconds
  • Memory Usage 1,725KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete