Page 1 of 1

Cannot execute external php file

Posted: Thu 4. Aug 2005, 12:24
by st3fek
Hi!

I'm using latest version of phpwcms, but I have a little problem with {PHP:my_external_file.php} tag.

I have simple code (which found on this forum) - it get the top category ID. I need this to put this ID into flash file, which is located in header.

Code: Select all

$check_id = $GLOBALS['content']['cat_id'];
$struct_id = $GLOBALS['content']['struct'][$check_id]['acat_struct'];
$nav_id = $check_id;

while ($struct_id != 0) {
$nav_id = $struct_id;
$struct_id = $GLOBALS['content']['struct'][$struct_id]['acat_struct'];
}

$Number = $GLOBALS['color']['randnr'];

echo '
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="750" height="150" id="p_info'.$Number.'" align="">
<param name="movie" value="img/swf/p_info'.$Number.'.swf?p='.$nav_id.'"><param name="menu" value="false"><param name="quality" value="high"><param name="wmode" value="transparent"><param name="bgcolor" value="#FFFFFF">

<embed src="img/swf/p_info'.$Number.'.swf?p='.$nav_id.'" menu="false" quality="high" wmode="transparent" bgcolor="#FFFFFF" width="750" height="150" name="p_info'.$Number.'" align="" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">
</embed>

</object>
';
On my local mashine it works fine, but after uploading everything on server it gives me a warning:

Code: Select all

Warning: strpos(): Empty delimiter. in /include/inc_front/front.func.inc.php on line 1642
When I put this code directly in [PHP] // code frome above [/PHP], there isn't any problem. However, this isn't good solution for me.

Do you have any ideas how to fix this? [/code]

Posted: Thu 4. Aug 2005, 12:41
by pepe
Don't forget, to put your code into the following delimiters!

<?PHP
.
.
.

?>

Posted: Thu 4. Aug 2005, 12:52
by st3fek
Thx, but I'm not begginer in PHP. ;)
That's not it. :(
Somehow, {PHP:my_external_file.php} can't see variable "my_external_file.php", even than file exists.
I don't have any idea what can be wrong.

Posted: Thu 4. Aug 2005, 12:57
by pepe
I always put my php.scripts into the special directory ......./scripts
and use then:

{PHP:scripts/my_external_file.php}

so the call "finds" the scripts :lol: and works:::

Posted: Thu 4. Aug 2005, 13:15
by st3fek
Ok, I have my scripts in subfolder too, but it still don't working.
{PHP:...} tag:

{PHP:phpwcms_template/inc_pinfo/GetRandomFlash.php}

Posted: Thu 4. Aug 2005, 14:05
by Pappnase
hallo

schau mal in die conf.inc.php
[quote=http://www.phpwcms-docu.de/index.php?conf.inc.php_de]
$phpwcms["allow_remote_URL"] = 0; Wenn Sie im {PHP:...} Tag URL aufrufen wollen müssen Sie diesen Wert auf 1 setzten. Wert: 0 = URL erlaubt (standard) / 1 = URL verboten[/quote]

Posted: Thu 4. Aug 2005, 14:18
by st3fek
Pappnase, can you please write your post in english? I don't understand german... :/

# EDIT #
I've checked english version of manual and set this variable to 1 (it was 0), but is remote URL dosn't mean that it should include external file from other site? Howewer, it didn't help.

Posted: Thu 4. Aug 2005, 14:31
by pico
Hi

Pappnase means:

look into your conf.inc.php and set

Code: Select all

$phpwcms["allow_remote_URL"] = 0;
to

Code: Select all

$phpwcms["allow_remote_URL"] = 1;

Posted: Thu 4. Aug 2005, 14:36
by st3fek
I did that, but nothing changes. Warning is still on the top of page.

Posted: Thu 4. Aug 2005, 14:44
by cyrano
sorry about ot exactly know what's wrong - may be the used script isn't working right?
May be you try another external php script to check that it depends on the used code?

btw: you have a quiet nice photo gallery - great macro shots.

Posted: Thu 4. Aug 2005, 15:19
by st3fek
cyrano wrote:sorry about ot exactly know what's wrong - may be the used script isn't working right?
May be you try another external php script to check that it depends on the used code?
This script is correct for sure, because I've pasted it in [PHP][/PHP] tag and it working fine. I've made also very simple script, and put it into header, but the same problem was here - it dosn't working.
I wrote:

Code: Select all

<?PHP

echo '--- true <b>true</b> ---';

?>
but nothing was printed on page.
cyrano wrote: btw: you have a quiet nice photo gallery - great macro shots.
Thanks. :) I like macro photography, but I'm still learning...

Here is it!

Posted: Thu 4. Aug 2005, 20:06
by zayebis
Find this code in include\inc_front\front.func.inc.php in the row about 1627 (function include_ext_php()). See the last row of code example:

$this_path = str_replace("\\", '/', dirname(realpath($inc_file)));
$this_path = preg_replace('/\/$/', '', $this_path);

$root_path = str_replace("\\", '/', realpath(PHPWCMS_ROOT));
$root_path = preg_replace('/\/$/', '', $root_path);

(HIER!) if(strpos($this_path, $root_path) === 0) $t = 1;

I don't know why the author checks if your path includes the root. You have to write {PHP:your_root/your-script.php} or check your PHPWCMS_ROOT or add $this_path = PHPWCMS_ROOT."/"; and so one....

Enjoy it!

Posted: Fri 5. Aug 2005, 08:09
by st3fek
zayebis, thanks! It help :)
I just did that:

Code: Select all

1642 		// if(strpos($this_path, $root_path) === 0) $t = 1;
1643		 $t = 1;
Because my PHPWCMS_ROOT gives "/" ( $phpwcms["root"] = ""; )
Well, this is only temporary solution - I'll work on it when I come back home.