$_POST array not accessible by external class mPDF

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm

$_POST array not accessible by external class mPDF

Post by rotezecke »

not sure if this problem is CMSMS related at all but i'm at a loss.

i have a form that is submitted to a very basic page (template only contains {content}). the content only contains a plugin i wrote. previously, the form action was kept external, but once i realised how easy it is to turn scripts into plugins, i did so. all works well.

now i tried to include mPDF in that plugin. which also works well.

mPDF in its simplest form would look like this:

Code: Select all

  $html = '<h1>Name: ' . $_POST['firstname'] .'</h1>';
  require('mpdf/mpdf.php'); 
  $mpdf=new mPDF();
  $mpdf->WriteHTML($html);
  $mpdf->Output();
  exit();
all this works well, except that the pdf would only print "Name: "

when i echo $html instead, it prints correctly: "Name: rotezecke". print_r($_POST) also shows what is expected.

is there something in CMSMS preventing $_POST to be accessed by external classes, and if so, how can I work around this?

----------------------------------------------

Cms Version: 1.11.12

Installed Modules:

CMSMailer: 5.2.2
FileManager: 1.4.5
MenuManager: 1.8.6
ModuleManager: 1.5.8
News: 2.14.4
CGSmartImage: 1.17.2
Search: 1.7.11
TinyMCE: 2.9.12
CGSimpleSmarty: 1.7.4
CGExtensions: 1.45
CGBlog: 1.12.9
CGFeedback: 1.6.8
Captcha: 0.5.2
FormBuilder: 0.8.1.1
JQueryTools: 1.3.4
GBFilePicker: 1.3.3


Config Information:

php_memory_limit:
process_whole_template:
max_upload_size: 2000000
url_rewriting: mod_rewrite
page_extension: .html
query_var: page
image_manipulation_prog: GD
auto_alias_content: true
locale:
default_encoding: utf-8
admin_encoding: utf-8
set_names: true


Php Information:

phpversion: 5.4.36-1~dotdeb.1
md5_function: On (True)
gd_version: 2
tempnam_function: On (True)
magic_quotes_runtime: Off (False)
E_STRICT: 0
E_DEPRECATED: 0
memory_limit: 256M
max_execution_time: 30
output_buffering: 4096
safe_mode: Off (False)
file_uploads: On (True)
post_max_size: 8M
upload_max_filesize: 2M
session_save_path: /var/lib/php5 (1733)
session_use_cookies: On (True)
xml_function: On (True)
xmlreader_class: On (True)


Server Information:

Server Api: apache2handler
Server Db Type: MySQL (mysql)
Server Db Version: 5.6.19
Server Db Grants: Found a "GRANT ALL" statement that appears to be suitable
Server Time Diff: No filesystem time difference found


----------------------------------------------
chandra

Re: $_POST array not accessible by external class mPDF

Post by chandra »

$_POST is a server side var and there's nothing inside CMSMS which limit the access to server side vars.

Include mPDF at the first line of your script so it will know the var $html too ;).

Maybe a look to the sources of this project

http://dev.cmsmadesimple.org/projects/pdf

could be helpful too.
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm

Re: $_POST array not accessible by external class mPDF

Post by rotezecke »

i turned my action script from a CMSMS plugin to an external file, updated a few variables, and Bob's your uncle.

could the pretty URL redirects empty the post array? but if that's the case, how come they arrive at all? anyway, workaround found, but not sure why this happens.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: $_POST array not accessible by external class mPDF

Post by calguy1000 »

chandra is correct $_POST is a server provided variable. and nothing inside of CMSMS touches it. I have tested this numerous times.

So any difficulties you may be having are entirely related to your scripts.
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.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: $_POST array not accessible by external class mPDF

Post by velden »

rotezecke wrote:could the pretty URL redirects empty the post array?
If the rewrite_url is initiating a browser redirect then I think the post request is turned into a get request without all parameters.

You could see that happen with a web inspector.

The default .htaccess that comes with cmsms has some conditions that do prevent post requests from being redirected. This could the/one reason.
Post Reply

Return to “The Lounge”