GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Simple PHP Include Question... Help Please (https://gfy.com/showthread.php?t=1048383)

TheSquealer 12-03-2011 06:29 PM

Simple PHP Include Question... Help Please
 
in this file:
http://www.domain-one.com/folderone/...lename-one.php

I want to use PHP to include a file located here:
http://www.domain-two.com/folderone/...lename-two.php

I can't seem to get it to work.

I've been looking around for answers and there seems to be a few different ways to do it and I can't get any to work :(

Help!?

SmokeyTheBear 12-03-2011 06:34 PM

Quote:

Originally Posted by TheSquealer (Post 18605233)
in this file:
http://www.domain-one.com/folderone/...lename-one.php

I want to use PHP to include a file located here:
http://www.domain-two.com/folderone/...lename-two.php

I can't seem to get it to work.

I've been looking around for answers and there seems to be a few different ways to do it and I can't get any to work :(

Help!?

<?@readfile("http://www.domain-two.com/folderone/foldertwo/filename-two.php");?>

cam_girls 12-03-2011 06:41 PM

I can't see the files,

but the file you read in should just be some functions, no < H T M L > or < ? p h p

just like you copied and pasted it into the main file.

include 'http://site.com/secondfile.php'

should work!

Do a test, copy the 2nd file into your main file - same error message?

sarettah 12-03-2011 06:51 PM

Quote:

Originally Posted by TheSquealer (Post 18605233)
in this file:
http://www.domain-one.com/folderone/...lename-one.php

I want to use PHP to include a file located here:
http://www.domain-two.com/folderone/...lename-two.php

I can't seem to get it to work.

I've been looking around for answers and there seems to be a few different ways to do it and I can't get any to work :(

Help!?

Are the domains on the same server or different servers? Also, Nix or Win?

If they are on the same server then include the file from domain 2 using the full path to the file, not the url.

If they are not on the same server then if you are on win you cannot use include to pull it in, if you are on nix you can use include using the url if allow_url_include is set to true in your php.ini file.


.

SmokeyTheBear 12-03-2011 06:51 PM

Quote:

Originally Posted by cam_girls (Post 18605254)
I can't see the files,

but the file you read in should just be some functions, no < H T M L > or < ? p h p

just like you copied and pasted it into the main file.

include 'http://site.com/secondfile.php'

should work!

Do a test, copy the 2nd file into your main file - same error message?

huh ?....

Babaganoosh 12-03-2011 06:53 PM

If allow_url_fopen is disabled on your server you won't be able to do it in php.

SmokeyTheBear 12-03-2011 07:00 PM

<?php
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,'http://example.com/folder/file.html');
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1) ;
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
echo $buffer;
?>

raymor 12-03-2011 07:21 PM

Quote:

Originally Posted by sarettah (Post 18605264)
If they are on the same server then include the file from domain 2 using the full path to the file, not the url.

Do that. If using the URL works, your server admin fucked up and if the server had been live for more than 48 hours it's probably hacked by now.

Quote:

Code:

<?@readfile("http://www.domain-two.com/folderone/foldertwo/filename-two.php");?>

That's about par for the course with PHP code - three errors in one line. Do not use that.

SmokeyTheBear 12-03-2011 07:29 PM

at the very least post something. my suggestions both work.. what you have posted does not :)

raymor 12-03-2011 07:36 PM

Quote:

Originally Posted by sarettah (Post 18605264)
Are the domains on the same server or different servers? Also, Nix or Win?

If they are on the same server then include the file from domain 2 using the full path to the file, not the url.

Do that. Use the path, not the URL. Full path or relative path is OK.
The relative path is less likely to break when you move servers.

Quote:

if you are on nix you can use include using the url if allow_url_include is set to true in your php.ini file.
allow_url_include requires allow_url_fopen.
allow_url_fopen requires stupid.
Therefore include(url) requires being stupid.

Use SmokeyTheBear's cURL code if they are on different servers. Be aware that's not like a PHP include, as you're getting the OUTPUT of the remote PHP script, not it's contents.


Quote:

Originally Posted by SmokeyTheBear (Post 18605243)
<?@readfile("http://www.domain-two.com/folderone/foldertwo/filename-two.php");?>

Smokey was right on the cURL code, but this line is typical for PHP code. Typical because it has three errors in one line of code.

raymor 12-03-2011 08:26 PM

Quote:

Originally Posted by SmokeyTheBear (Post 18605313)
at the very least post something. my suggestions both work.. what you have posted does not :)

My post was submitted before it was complete. Sorry about that. I meant to at least acknowledge that your cURL code looks good (though I didn't heavily analyze it).

raymor 12-03-2011 08:31 PM

Btw be very, very careful if there are any variables in the path or especially a URL. The bad guys can be very tricky about sneaking stuff into variables so you end up executing whatever they put at http://hacker.com/yourfucked.php?you.com/yourscript.php

Also you said "it doesn't work". What does the error log tell you about WHY it didn't work? When you say "it doesn't work", the second half of that sentence is the important part - it doesn't work and the error log says that's because ...

The very important message in the error log assumes you don't prefix the statement with "@" as you sometimes see people do. "@" means "when this fails don't tell me why and don't stop processing, just keep going as pretending it worked, without telling me what's wrong". It could be useful if you know that the statement is SUPPOSED to fail sometimes.

sarettah 12-03-2011 09:10 PM

Quote:

Originally Posted by raymor (Post 18605324)
allow_url_include requires allow_url_fopen.
allow_url_fopen requires stupid.
Therefore include(url) requires being stupid.

Use SmokeyTheBear's cURL code if they are on different servers. Be aware that's not like a PHP include, as you're getting the OUTPUT of the remote PHP script, not it's contents.

I was only trying to tell the guy where his issue may lie, not making reccomendations.

Myself, unless I have control of the file I am pulling in, or it is on an extremely trusted site, I'm not pulling it in or pushing it out.

If I had this issue, on 2 different servers, with domains I control, I would probably just duplicate the file from server 1 on server 2. If the file was dynamic then I would use a curl solution like Smokey's.

but that just me.

cam_girls 12-03-2011 09:13 PM

Quote:

Originally Posted by SmokeyTheBear (Post 18605273)
<?php
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,'http://example.com/folder/file.html');
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1) ;
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
echo $buffer;
?>


Smokey can you help me with a script that uses $curl to send an XML request with POST?

I need to read the XML stats and populate my Aff Program tables.

sarettah 12-03-2011 09:35 PM

Quote:

Originally Posted by cam_girls (Post 18605419)
Smokey can you help me with a script that uses $curl to send an XML request with POST?

I need to read the XML stats and populate my Aff Program tables.

add curlopt_post and the curlopt_postfields to what smokey did.

curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS,"var=whatever&var1=whatever&var 2=whatever);

SmokeyTheBear 12-03-2011 09:48 PM

Quote:

Originally Posted by cam_girls (Post 18605419)
Smokey can you help me with a script that uses $curl to send an XML request with POST?

I need to read the XML stats and populate my Aff Program tables.

icq me or post variables and xml url

raymor 12-03-2011 09:56 PM

Quote:

Originally Posted by sarettah (Post 18605417)
I was only trying to tell the guy where his issue may lie, not making reccomendations.

Myself, unless I have control of the file I am pulling in, or it is on an extremely trusted site, I'm not pulling it in or pushing it out.

If I had this issue, on 2 different servers, with domains I control, I would probably just duplicate the file from server 1 on server 2. If the file was dynamic then I would use a curl solution like Smokey's.

but that just me.

:thumbsup:

Since I've called allow_fopen_url "stupid", I should acknowledge that I've written stupid code. A lot of what I've learned I didn't learn from a book, but from doing stupid. Heck, most of what I write wouldn't make it into the kernel, Linus would call it stupid. So my comment is only that the function should be avoided and shouldn't be interpreted as a slam on PEOPLE who use it.

cam_girls 12-03-2011 10:15 PM

Quote:

Originally Posted by SmokeyTheBear (Post 18605454)
icq me or post variables and xml url


Thanks! I'm setting up the server today so I'll get what I can on there first so you can have a look. :thumbsup

sarettah 12-04-2011 04:09 PM

Know what I love about threads like this?

Guy comes in and asks a question.

4 different programmers and cam_girls come in and offer up solutions, reccomendations and what not and there is no trace of the original poster.

Glad cam_girls got his hook up with smokey though. At least someone got something from the conversation.

Makes ya wonder, ya know?



.

redwhiteandblue 12-04-2011 04:42 PM

I bet none of the above solutions will work anyway because the OP probably wants to include the source file not the output file.

TheSquealer 12-05-2011 06:41 AM

I want to thank everyone for their suggestions. I am going to keep playing with this today and try all the solutions. I know there are security concerns as well, which adds a bit to the mind fuck of what I thought was a simple thing.

TheSquealer 12-05-2011 07:01 AM

Quote:

<?@readfile("http://www.domain-two.com/folderone/foldertwo/filename-two.php");?>
Is there a reason not to do this? What are the errors?

It works anyway.

u-Bob 12-05-2011 07:12 AM

Quote:

Originally Posted by TheSquealer (Post 18607640)
Is there a reason not to do this? What are the errors?

It works anyway.

Short open tags don't work on all servers (got to set short_open_tag to On in php.ini) so the script isn't as portable as it should be (might dump php code to the surfers browser...)
Using php short tags can also cause problems when using xml directives.

SmokeyTheBear 12-05-2011 09:55 AM

Quote:

Originally Posted by TheSquealer (Post 18607640)
Is there a reason not to do this? What are the errors?

It works anyway.

grammatical errors. i made it simple. it works , there are no security concerns.

cam_girls 12-05-2011 02:45 PM

Quote:

Originally Posted by SmokeyTheBear (Post 18605454)
icq me or post variables and xml url

I found a script to send a XML POST request but this is all it does.

http://camaffiliate.com/chron_get_xml_2.php
400 Bad Request


http://camaffiliate.com/chron_get_xml_2.txt

Can you see the problem? :thumbsup


All times are GMT -7. The time now is 04:54 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123