Page 1 of 1

How to get the value in my php program

Posted: Thu 11. Dec 2003, 04:43
by fatxu
i use {PHP:xxx} tags , it's worked well.
but there are thress questions.
1: my php program can't get the value from phpwcms ,
for example , http://www.mbank.cn/index.php?id=4,0,0,1,0,0&cat=1
I can't get the value of cat. how can i get it.

2:my php code don't know the position , i mean if i both include a same php code in news and download, my php code don't know where he is .

3:i can't use the tag like that . {PHP:demo.php?abc=123&h=23}

Posted: Thu 11. Dec 2003, 06:00
by fatxu
ok, i have solve the question 1.
by $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']

Posted: Fri 12. Dec 2003, 08:33
by fatxu
i change some code in front.func.inc.php. so i can transfer some value to my ext php.

Code: Select all

function include_ext_php($inc_file) {
	// includes an external PHP script file and returns
	// the result as string from buffered include content
	$ext_php_content = "";
	ob_start();
	$command=strpos($inc_file,"?");
	if ($command>0) 
	{
	parse_str(substr($inc_file,$command+1));
	$inc_file=substr($inc_file,0,$command);
	}
	include $inc_file;
	$ext_php_content = ob_get_contents();
	ob_end_clean();
	return $ext_php_content;
}
i can use it like that

Code: Select all

{PHP:showmoviecat.php?cat=1}

Posted: Fri 12. Dec 2003, 14:44
by sporto
That's really useful information. Thanks!

Posted: Fri 12. Dec 2003, 16:05
by frold
fatxu wrote:

Code: Select all

{PHP:showmoviecat.php?cat=1}
What is the idea of ..cat=1? I´m just curious..

Posted: Mon 15. Dec 2003, 04:36
by fatxu
i do more change on the code ,so i can get more value in my ext_php now.

Code: Select all

function include_ext_php($inc_file) {
	// includes an external PHP script file and returns
	// the result as string from buffered include content
	$ext_php_content = "";
	ob_start();
	$command=strpos($inc_file,"?");
	if ($command>0) 
	{
	$tmp=substr($inc_file,$command+1);
	$tmp=ereg_replace("&","&",$tmp);
	parse_str($tmp);
	$inc_file=substr($inc_file,0,$command);
	}
	include $inc_file;
	$ext_php_content = ob_get_contents();
	ob_end_clean();
	return $ext_php_content;
}
i can get value like this
{PHP:demo.php?t1=3&t2=4}

i have a question .

my ext_php code can get the var's value by URL
for example
http://www.xxxx.com/index.php?id=1,0,0,0,3&cat=3
my code can get id,cat value
but can't get the var's value from cookie.

it's important to my to get the cookie value.

now i use a temporary solution.

i change the index.php's name to main.php,and i create a new index.php

$sid is a var get value from cookie.

Code: Select all

<?php
$schema = $_SERVER['SERVER_PORT'] == '443' ? 'https' : 'http';
$host = strlen($_SERVER['HTTP_HOST'])?$_SERVER['HTTP_HOST']:$_SERVER['SERVER_NAME'];
$to="$schema://{$host}/main.php?".$_SERVER['QUERY_STRING']."&sid=$sid";
header("Location: $to");
?>
now ,my ext_php code can get the cookie value.
but i know ,it's not a good idea.
who can give me more advise.