Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2012-05-08 08:29:53

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: migrating

colak wrote:

Now that includes are not accepted

Are not accepted where? Includes are accepted, valid. If you are referring to previous mentions concerning rah_external_output, those where about non-local filesystem files, where actual content where transferred over internet.

file_get_contents

File_get_contents is a file function and just merely reads files. include on the other hand is for evaluating PHP source code. file_get_contents will not evaluate (i.e. execute) any code, it just reads files.

<?php […] ?>

Let’s start with the tags. Use of raw PHP is deprecated, and the support will be removed in the next release, Textpattern v4.5.0. Instead of those, please see and use <txp:php> tags when working with PHP block in page and form templates.

nothing is […] what might be going wrong?

Try to turn Debugging mode on. Potentially one the file paths could be incorrect (using absolute paths might not hurt), or you may not have rights to the directory.

As the random image script goes, you probably could minify it something much more smaller and put it into a single PHP in your page template. For example:

background: url('/rando/<txp:php>
	$f = array_filter((array) glob(txpath.'/../rando/*.{png,jpg,gif}', GLOB_NOSORT|GLOB_BRACE), 'is_file');
	echo $f ? basename($f[mt_rand(0, count($f)-1)]) : '';
</txp:php>');

Edit. glad you got it sorted. Seems you migrated to Textpattern’s own image management and <txp:images /> tag or similar :)

Last edited by Gocom (2012-05-08 08:34:51)

Offline

#14 2012-05-08 08:45:28

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: migrating

Gocom wrote:

Hi Jukka

Are not accepted where? Includes are accepted, valid. If you are referring to previous mentions concerning rah_external_output, those where about non-local filesystem files, where actual content where transferred over internet.

My new server at joyent does not like includes and it initially broke all my pages which were using the include function

File_get_contents is a file function and just merely reads files. include on the other hand is for evaluating PHP source code. file_get_contents will not evaluate (i.e. execute) any code, it just reads files.

It is nevertheless this code which solved my problems a few days ago

Edit. glad you got it sorted. Seems you migrated to Textpattern’s own image management and <txp:images /> tag or similar :)

Yes :) I used <txp:images limit="1" category="random_images" sort="rand()"><txp:image_url /></txp:images> and added body{background: url(<?php echo file_get_contents('path_to_ext_output/?rah_external_output=myextTxpTags');?>); and all was sorted.

Thanks soo much for your intervention nevertheless


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#15 2012-05-08 13:39:01

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: migrating

OK… :) There are still problems.

On forum.neme.org I have a little file which calls for rah_external_output.

I used to be able to get it by using <?php include($DOCUMENT_ROOT . "http://mysite.tld/?rah_external_output=bar"); ?> but not any more.

// does not work (the whole forum page goes white)
<?php include($DOCUMENT_ROOT . "http://mysite.tld/?rah_external_output=bar"); ?>

// same as above
<?php include 'http://mysite.tld/?rah_external_output=bar'; ?>

//same as above
<?php include("http://mysite.tld/?rah_external_output=bar"); ?>

// semi works as the forum page is rendering but the external output is not fetched
<?php echo file_get_contents('http://mysite.tld/?rah_external_output=bar'); ?>

any advice would be appreciated


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#16 2012-05-09 14:08:42

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: migrating

Maybe I should clarify the difference between my old server up and the new one. In the old server the forum was residing inside the main domain. After Joyend’s advice, now the forum is working like an independent domain. The includes I was using in the previous setup were cross-domain (fetching content from our sites) except the forum as I mentioned earlier and everything was working wonderfully.

<?php echo file_get_contents('http://mysite.tld/?rah_external_output=bar'); ?> works fine for the txp sites but for the forum, it is not parsed.

Can anyone point me to the right direction on how I can display this txp content?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#17 2012-05-09 22:55:57

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Re: migrating

Try using Curl

I had a similar problem a few years ago with get_file_contents and include, both of which had been turned off or something on the server and the admins told me to use Curl…. I did, and it worked.

Not sure on the technicalities though

Offline

#18 2012-05-10 05:47:44

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: migrating

Thanks tye

I tried

<?php
	$curl = curl_init();
	curl_setopt ($curl, CURLOPT_URL, 'http://mysite.tld/?rah_external_output=bar');
	curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
	echo curl_exec ($curl);
	curl_close ($curl);
?>

and

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://mysite.tld/?rah_external_output=bar');
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$file = curl_exec($ch);
$http = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $file !== false && $http == '200' ? $file : 'Error appeared. Sad face.';
?>

neither of which returned any results.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#19 2012-05-10 06:33:12

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: migrating

[SOLVED]… I had an include in my rah page which I forgot to change.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#20 2012-05-10 07:23:47

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Re: migrating

:) Phew… thought I was going to have to pretend I knew what I was doing then

Offline

#21 2012-05-10 08:02:00

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: migrating

tye wrote:

:) Phew… thought I was going to have to pretend I knew what I was doing then

lol. No worries, your suggestion pushed me to think more laterally anyway and assisted in solving the issue.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

Board footer

Powered by FluxBB