Invision Power Services: php "file" include - Invision Power Services

Jump to content

General Chat

Our community chat forum areas are for off-topic discussion only. Please do not post topics about IPS or its products and services here. We provide other forum areas for IPS discussion.

Do you need technical support on IPS products or services?

You can obtain support via the client area, or you can try to obtain peer-to-peer support at IPS Resources.

Did you find a bug in one of our products?

If you believe you've found a bug please post it to the bug tracker.

Have a suggestion or feedback?

Use the company feedback forum or appropriate product feedback forum. You can also submit a ticket in your client area if it's a private matter.
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

php "file" include something thats puzzling me ... Rate Topic: -----

#1 User is offline   Rοb Icon

  • TO LET
  • Icon
  • View blog
  • Group: +Active Customers
  • Posts: 1,028
  • Joined: 02-September 03

Post icon  Posted 01 December 2004 - 01:10 AM

Hi folks :)

I am trying to use THIS page as a php include on a website but i cant.

e.g

<?php include "http://oaserv.ath.cx:7668/>Oasiz" ?>


I have viewed properties on that particular page and it says "Type - File" (whatever that means).

Is there any way i can include it on a web page?

If so, how? (or if not, what are my other options i.e ways to get round it)

I hope you brainiacs can help because im stumped :P

All the best,

Rob
Sky TV | Sky TV (Ireland) | Oasiz Chat (Ajax IRC Webchat)
0

#2 User is offline   Luke Icon

  • Too detail oriented
  • Icon
  • View blog
  • Group: +Active Customers
  • Posts: 5,480
  • Joined: 14-August 04
  • Location:USA

Posted 01 December 2004 - 02:33 AM

Quote

Hi folks  :)

I am trying to use THIS page as a php include on a website but i cant.

e.g

<?php include "http://oaserv.ath.cx:7668/>Oasiz" ?>


I have viewed properties on that particular page and it says "Type - File" (whatever that means).

Is there any way i can include it on a web page?

If so, how? (or if not, what are my other options i.e ways to get round it)

I hope you brainiacs can help because im stumped :P

All the best,

Rob


Well if its not a php file you need to use fopen and fread. Include includes PHP source. It doesnt output HTML source.

Here's an example from php.net:

<?php
$filename = "somefile.txt";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
?>


http://us2.php.net/m...ction.fopen.php
http://us2.php.net/m...ction.fread.php
Luke
0

#3 User is offline   Michael_C Icon

  • The monkey died.
  • PipPipPipPipPipPip
  • View blog
  • Group: Members
  • Posts: 2,731
  • Joined: 21-July 04
  • Location:New Zealand

Posted 01 December 2004 - 02:47 AM

No, you can include plain text files fine using include.
0

#4 User is offline   Michael_C Icon

  • The monkey died.
  • PipPipPipPipPipPip
  • View blog
  • Group: Members
  • Posts: 2,731
  • Joined: 21-July 04
  • Location:New Zealand

Posted 01 December 2004 - 02:50 AM

Try:
<?php include "http://oaserv.ath.cx:7668/&gt;Oasiz"; ?>

0

#5 User is offline   Rοb Icon

  • TO LET
  • Icon
  • View blog
  • Group: +Active Customers
  • Posts: 1,028
  • Joined: 02-September 03

Posted 01 December 2004 - 02:59 AM

Hi, cheers for the replies :)

Ive tried those suggestions and unfortunately it still wont work:(

Its very odd but it must be possible!
Sky TV | Sky TV (Ireland) | Oasiz Chat (Ajax IRC Webchat)
0

#6 User is offline   marcele Icon

  • Spam Happy
  • Icon
  • View blog
  • Group: +Active Customers
  • Posts: 754
  • Joined: 26-February 04
  • Location:Edmonton, Alberta, Canada

Posted 01 December 2004 - 03:10 AM

Windows versions of PHP prior to PHP 4.3.0 do not support accessing remote files via this function, even if allow_url_fopen is enabled.

What version of php are you using and do you have allow_url_fopen is enabled?

I suggest looking at :
http://us2.php.net/include/
0

#7 User is offline   Rοb Icon

  • TO LET
  • Icon
  • View blog
  • Group: +Active Customers
  • Posts: 1,028
  • Joined: 02-September 03

Posted 01 December 2004 - 03:20 AM

PHP Version 4.3.8 and allow_url_fopen is enabled
Sky TV | Sky TV (Ireland) | Oasiz Chat (Ajax IRC Webchat)
0

#8 User is offline   Michael_C Icon

  • The monkey died.
  • PipPipPipPipPipPip
  • View blog
  • Group: Members
  • Posts: 2,731
  • Joined: 21-July 04
  • Location:New Zealand

Posted 01 December 2004 - 04:21 AM

This definately works.
<?php
$fp = @fsockopen("oaserv.ath.cx", 7668, $errno, $errstr, 5);
if(!$fp) {
	echo "Error: Could not open socket! $errstr ($errno)";
}
else {
	$request = "GET /&gt;Oasiz HTTP/1.1\r\n";
	$request .= "Host: oaserv.ath.cx\r\n";
	$request .= "Connection: Close\r\n\r\n";
	
	fwrite($fp, $request);
	$str = "";
	while (!feof($fp)) {
  $str .= fgets($fp, 128);
	}
	
	@fclose($fp);
	
	echo $str;
}
?>

0

#9 User is online   Mat (FDNZ) Icon

  • Let's say my yearly license expired in...
  • Icon
  • View blog
  • Group: +Active Customers
  • Posts: 3,851
  • Joined: 07-November 03
  • Location:Auckland, NZ

Posted 01 December 2004 - 09:03 AM

Remove > from the filename. It's invalid in filenames anyway.
0

#10 User is offline   Rοb Icon

  • TO LET
  • Icon
  • View blog
  • Group: +Active Customers
  • Posts: 1,028
  • Joined: 02-September 03

Posted 02 December 2004 - 02:06 PM

Thank you, that code works! (Michael_C)

Its all much appreciated, thanks to all those who replied :)
Sky TV | Sky TV (Ireland) | Oasiz Chat (Ajax IRC Webchat)
0

#11 User is offline   Stephen Icon

  • Meet Jay
  • PipPipPipPipPipPipPipPipPip
  • View blog
  • Group: Members
  • Posts: 18,141
  • Joined: 22-March 02
  • Location:London, England

Posted 02 December 2004 - 03:37 PM

if you opened the URL in your browser you will see that the browser automatically corrects the invalud character into a URL safe one

<?php include("http://oaserv.ath.cx:7668/%3EOasiz"); ?>


should work

<edit>maybe not, seems to get weird output on my server

Quote

Warning: main(http://oaserv.ath.cx:7668/%3EOasiz): failed to open stream: HTTP request failed! <br><font color="#848673"><b>Sorry, we have found no matching results!<br><br> Click <a href="http://www.oasiz.com/chat/faf.ph in c:\inetpub\wwwroot\test.php on line 1

Posted Image Posted Image
0

#12 User is offline   Michael_C Icon

  • The monkey died.
  • PipPipPipPipPipPip
  • View blog
  • Group: Members
  • Posts: 2,731
  • Joined: 21-July 04
  • Location:New Zealand

Posted 02 December 2004 - 03:53 PM

Quote

if you opened the URL in your browser you will see that the browser automatically corrects the invalud character into a URL safe one

<?php include("http://oaserv.ath.cx:7668/%3EOasiz"); ?>


should work

<edit>maybe not, seems to get weird output on my server

I tried a few methods but the only thing that seems to work was opening a socket and requesting it via HTTP. Not the most efficient method ubt its the only one that seems to work.
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users