Variables in the $_REQUEST array

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
aacraig

Variables in the $_REQUEST array

Post by aacraig »

I've inherited a project and am trying my best to make some changes to a web portal.

I am using CMSMS on a linux system.  Sorry, I didn't install it myself, and can't find any version information in the control panel of the CMS itself and only have FTP access to the server, so no version info there either :(  I believe it's running under Apache, but error pages are redirected, so no server signature, so I can't even guarantee that's correct.

My question is this:

We sell products through a service (1shoppingcart.com) that allows us to have customers redirect to us after purchasing a product.  The request that comes from 1shoppingcart includes many variables that store info about the transaction.

If I set up a PHP page outside of CMSMS, the following prints a myriad of information:

Code: Select all

foreach($_REQUEST as $k => $v)
	echo "$k: $v<br>";
However, when I put the same PHP code into a user defined tag (as we have many thank you pages, so 1shoppingcart.com may send the customer to any number of them after a sale) the same code ends up empty.

Any help on how to pick up these variables from within CMSMS would be appreciated!!
Pierre M.

Re: Variables in the $_REQUEST array

Post by Pierre M. »

Hello,
aacraig wrote: ...can't find any version information in the control panel of the CMS itself and only have FTP access to the server
In my admin panel at the bottom of the page, I see "CMS Made Simple 1.1.2" => 1.1.2.
aacraig wrote: ...that allows us to have customers redirect to us after purchasing a product.  The request that comes from 1shoppingcart includes many variables that store info about the transaction.

If I set up a PHP page outside of CMSMS, the following prints a myriad of information:

Code: Select all

foreach($_REQUEST as $k => $v)
	echo "$k: $v<br>";
However, when I put the same PHP code into a user defined tag (as we have many thank you pages, so 1shoppingcart.com may send the customer to any number of them after a sale) the same code ends up empty.
In UDTs, things like echo $_SERVER["HTTP_USER_AGENT"]; should work.
Hence SCRIPT_FILENAME, PATH_INFO, QUERY_STRING...

Pierre M.
aacraig

Re: Variables in the $_REQUEST array

Post by aacraig »

I've made a test case to illustrate the issue.

First, I created a UDT called 'test'.  Here's the code:

Code: Select all

	echo "REQUEST<br>";
	foreach($_REQUEST as $k => $v)
		echo "$k: $v<br>";
	echo "POST<br>";
	foreach($_POST as $k => $v)
		echo "$k: $v<br>";
	echo "GET<br>";
	foreach($_GET as $k => $v)
		echo "$k: $v<br>";
	echo "SERVER<br>";
	foreach($_SERVER as $k => $v)
		echo "$k: $v<br>";
Next, I created a page called "Aaron's Test Page", which simply calls the test tag:

Code: Select all

{test}
If I then call up the page passing parameters as GET:

Code: Select all

http://exoticpublishing.com/aaron-s-test-page?foo=bar
I can see my bar value, both in $_REQUEST and in $_GET:

Code: Select all

REQUEST
page: aaron-s-test-page
foo: bar
CMSSESSIDa20aab3f: 99ef2dfd25f3f3e9d1b59658de240e43
__utma: 1.512717982.1189842767.1189842767.1189874168.2
__utmc: 1
__utmz: 1.1189842767.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none)
__utmb: 1
POST
GET
page: aaron-s-test-page
foo: bar
If, however, I create an HTML form:

Code: Select all

<form action="http://mydomain.com/aaron-s-test-page" method="POST">
	<input type="text" name="foo" value="bar">
	<input type="submit" value="go">
</form>
and hit the "go" button, my foo parameter does not show up in the POST data:

Code: Select all

REQUEST
page: aaron-s-test-page
CMSSESSIDa20aab3f: 99ef2dfd25f3f3e9d1b59658de240e43
__utma: 1.512717982.1189842767.1189842767.1189874168.2
__utmc: 1
__utmz: 1.1189842767.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none)
__utmb: 1
POST
GET
page: aaron-s-test-page
I'm wondering if this is because in the URL rewrite rule the engine passes the GET parameters along because they are part of the path, but perhaps the mechanism that redirects the request to the CMS system does not also pass POST variables?

Thanks!
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Variables in the $_REQUEST array

Post by calguy1000 »

it must be a problem with the server configuration or something because I've done similar things (and even posted about doing these things in the forum) and had no problems.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
aacraig

Re: Variables in the $_REQUEST array

Post by aacraig »

Great, could you point me to the threads that talk about it?  Perhaps I can figure out what might be going on with the configuration...

Thanks!
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Variables in the $_REQUEST array

Post by calguy1000 »

Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
aacraig

Re: Variables in the $_REQUEST array

Post by aacraig »

Thanks for your quick response!

In the thread you cite, however, you only use the $_REQUEST variable.  I'm wondering what happens if you send the parameters in a POST request.  As you can see in my test case example, my code works just fine with a GET request, but does not get the parameters passed through in the POST.

I'd expect that your example wouldn't work if you were to try to run that code with a POST, unless it's an issue with my config.php. 

Just as a note, I don't currently have use_smarty_php_tags set to true, but I don't think I need to as I am putting this code inside a UDT.

Thanks again for the help.
aacraig

Re: Variables in the $_REQUEST array

Post by aacraig »

I've hunted around the root directory of the server, looking for how things get redirected into the CMSMS system (couldn't find anything about this in the docs, though I'm sure it's there somewhere!) and have discovered the redirect rules in the .htaccess page.  Looks to me like anything that would throw a 404 error (that is, a non-existent file or directory in the request) gets redirected to index.php, adding the query bit onto the end.  And sure enough, index.php is the entry point for the CMSMS system.

Clearly, this method of redirecting pages to index.php will lose any POST request parameters getting passed through.

I've reviewed the code you mention in your thread, and have copied and pasted it into my UDT.  However, $_SERVER['PHP_SELF'] returns "index.php", so when I hit submit, I never get back to my original page -- I just go to the main page of the site.

What am I doing wrong??
Pierre M.

Re: Variables in the $_REQUEST array

Post by Pierre M. »

Hello again,

have you found version information ? May be what you need to run Calguy's UDT with PHP_SELF is upgrade to current stable ?

Pierre M.
Locked

Return to “CMSMS Core”