MODx POST data Handling in snippet - modx-revolution

I am new to Modx and I want to write a custom but of code in a snippet that handles incoming post data. Unfortunately I can't seem to be able to collect the post data using $_POST.
Can anyone point me in the right direction please?
Cheers
John

Also, if you do not wish to cache the results of the snippet call use [[!getPost]] rather than [[getPost]].

I've used
<?php
var_dump($_POST);
and [[getPost]]
and it worked (I got an array of 0, but I didn't send anything in post)

Vardump is a VERY bad idea.
The MODx Revolution Object is huge...
Please try:
<?php
print_r($_REQUEST);

Related

Can I force OpenLayers 5 to send POST request?

Here is my issue.
I have to filter an ImageLayer with OpenLayers 5, so I prepared this kind of code :
const params = layerToFilter.getSource().getParams();
delete params.CQL_FILTER;
params.CQL_FILTER = myFilter;
layerToFilter.getSource().updateParams(params);
This code works fine, but not if "myFilter" variable is a too big string.
For example, with a filter like 'FEATUREID IN (1,2,3,4...1000)', I get a HTTP 414 URI too long.
My question is : is there a way to force OpenLayers 5 to use POST request instead of GET request when it tries to refresh map layers ?
I have some workaround ideas like building a smaller filter and prepare a view for this filter on database side, or by making preprocessing also on database side, but it will be really easier if I could simply send POST request.
Any help or suggestion will be appreciated :-)
Many thanks in advance.
Geoserver can publish feature id as a property of a layer. So you dont have to use FEATUREID. You can use CQL_FILTER instead of FEATUREID
http://locahost:8080/?CQL_FILTER=id BETWEEN 1 AND 1000

How can I store comments for a post using Parse & Swift?

I'm honestly stumped as to how I could do this. I've been searching and trying out different methods for the past day or so and none have worked. What I'm basically trying to do is store comments for a post (Each row represents a post). I've been reading through the Parse documentation and have tried to implement some of the things that they have there into my code in order to achieve this, but that hasn't worked out either. If anybody could help me out, I'd be extremely greatful.
This exact task is the example provided in the documentation.
http://docs.parseplatform.org/ios/guide/#relational-data
You need to create a new class called "Comments" and then refrence its parent post as one of it's columns.

Dropping tables because of GET method?

I have simple question. I did GET form search to get ID of a show, so after code is executed, the url looks like this:
...show.php?showid=inserted number
So, is it possible to drop all tables only because I used GET method, and therefore, should I use POST?
Thanks in advance!
"This is the canonical explanation here on SO of how to prevent SQL injection: stackoverflow.com/questions/60174/… – Andy Lester Feb 13 at 23:12"
Thanks. I'm not sure how to post comment as an answer, but this satisfied me. I tried SQL injection into my table, but probably not related one:' or '1'='1
And I get this:
403
Forbidden
Access to this resource on the server is denied!
So that's all. Thank you guys once again.

Unable to post Attask custom data when creating a project

Trying to use the Attask API to post a new issue to a project. It works without posting cutom data. This works fine:
https://ourcompany.attask-ondemand.com/attask/api/task?projectID=&&status=NEW&priority=2&name=Test%20Project%20FOOBAR&description=test&estCompletionDate=2014-03-28T09:00:00:000-0700
However, I'm unable to post custom data. The url we use:
https://ourcompany.attask-ondemand.com/attask/api/task?projectID=&&status=NEW&priority=2&name=Test%20Project%20FOOBAR&description=test&estCompletionDate=2014-03-28T09:00:00:000-0700&DE%3ACUSTOMDATAFIELD=BLAH
The error we receive is:
{"error":{"class":"com.attask.common.InvalidParameterException","message":"category cannot be null","title":null,"msgKey":"exception.attask","attributes":[""],"code":0}}
I do not understand what it is asking. The Attask API documentation is not helpful here. What am I missing in my URL?
Thank you!
You need to also set the categoryID to the category which has the custom data field.
https://ourcompany.attask-ondemand.com/attask/api/task?projectID=&&status=NEW&priority=2&name=Test%20Project%20FOOBAR&description=test&estCompletionDate=2014-03-28T09:00:00:000-0700&DE%3ACUSTOMDATAFIELD=BLAH&categoryID=XXXX
This is also assuming that you are doing a POST action.

Pass variable to Google Custom Search Engine

Is it possible to pass a search variable into the Google Custom Search Engine that I have embedded on my website? I can get the search engine to work, but I can't pass it a term via POST (it's coming from a search button on other pages of the website)
I tried to hack the code I found here: http://code.google.com/apis/ajax/playground/?exp=search#hello_world
And this is what I have so far... ($q is the term I am passing to it)
<script type="text/javascript">
google.load('search', '1', {language : 'en'});
function OnLoad()
{
var customSearchControl = new google.search.CustomSearchControl('***my key****');
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
customSearchControl.draw('cse');
searchControl.execute("$q");
}
google.setOnLoadCallback(OnLoad);
</script>
Thanks
Sorry, I know it's a crappy answer, but you've actually got it right apart from referencing the wrong variable name. Oh, also, as an aside, I would also hope you're doing some kind of sanitisation on $q, in case someone posted something like this to your form: term"); alert("aha!
customSearchControl.draw('cse');
searchControl.execute("$q");
should be:
customSearchControl.draw('cse');
customSearchControl.execute("$q");
Also, thank you for the question - I was looking for how to do this myself!
This is to help anyone using PHP trying to accomplish this same goal. The example above uses...
customSearchControl.execute("$q");
to read the parameter being passes in. On a PHP site you would use...
customSearchControl.execute("<?php echo $_POST['your_paramter_name_here'];?>");
You could use $_GET or $_REQUEST if your parameter is not in the post.
Of course you should should sanitize the input first. Something like this is pretty weak but it's a start...
customSearchControl.execute("<?php echo htmlentities( trim( $_POST['your_paramter_name_here'] ), ENT_QUOTES );?>");
In case someone is looking for a bit more straight forward / simple solution. All you have to do is to pass search keywords into GET parameter named q (from your custom form into page where your GCS is), GCS will automatically use that search phrase.
Source: https://developers.google.com/custom-search/json-api/v1/using_rest

Resources