How to get the value in my php program

Get help with installation and running phpwcms here. Please do not post bug reports or feature requests here.
Post Reply
fatxu
Posts: 11
Joined: Tue 9. Dec 2003, 05:48
Location: Dalian,China
Contact:

How to get the value in my php program

Post 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}
fatxu
Posts: 11
Joined: Tue 9. Dec 2003, 05:48
Location: Dalian,China
Contact:

Post by fatxu »

ok, i have solve the question 1.
by $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']
fatxu
Posts: 11
Joined: Tue 9. Dec 2003, 05:48
Location: Dalian,China
Contact:

Post 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}
sporto
Posts: 160
Joined: Mon 10. Nov 2003, 18:01
Location: USA, Chicago

Post by sporto »

That's really useful information. Thanks!
frold
Posts: 2151
Joined: Tue 25. Nov 2003, 22:42

Post by frold »

fatxu wrote:

Code: Select all

{PHP:showmoviecat.php?cat=1}
What is the idea of ..cat=1? I´m just curious..
http://www.studmed.dk Portal for doctors and medical students in Denmark
fatxu
Posts: 11
Joined: Tue 9. Dec 2003, 05:48
Location: Dalian,China
Contact:

Post 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.
Post Reply