Jump to content

Ocs-server/Gfx4/get post headers

From KDE Community Wiki

GFX provides a class that automatically handles and parse GET and POST data. So instead of directly accessing those arrays you should use EHeader.


If you have to output your data you can use:

EHeader::out_get(string $name);
EHeader::out_post(string $name);


If you have to insert your data into database and you need them to be safe you can use:

EHeader::db_get(string $name);
EHeader::db_post(string $name);

These are now obsolete:
EHeader::secure_get(string $name);
EHeader::secure_post(string $name);


If you need all your data to be safe you can easily do:

EHeader::safeAll();


You can also set GET and POST manually using:

EHeader::add_get(string $key, string $value);
EHeader::add_post(string $key, string $value);


You can check existance of GET and POST manually using:

EHeader::exists_get(string $key);
EHeader::exists_post(string $key);


You can use this class to get/set cookie data via:

EHeader::get_cookie(string $key);
EHeader::set_cookie(string $key, $value);
EHeader::del_cookie(string $key);

This can result particularly useful when you need to use EModel's insert and update but not all the data comes from user request.


If you want to take those variables fast and you can't decide you can choose the unsafe way using:

EHeader::get(string $key);
EHeader::post(string $key);


If you have a string formed as a standard get key/value list (e.g. example=val&example2=val2) you can use this handy method to have that added to the module's stack.
EHeader::add_from_string(string $str);


You can get the script page with all exta data(&data=example?...) erased by using:
EHeader::erase_get_data(string $url);


EHeader can be configure in the generic config file of gfx, which can be located here: gfx3/config/generic.conf.php.

Example:

<?php die("You cannot see config in here."); ?>
protectheaders|yes
protectheaders|no