MODX Revolution and Formit plugin: not sending mail attachments - modx-revolution

Using MODX Revolution and Formit, I try to attach a file to a contact form. The mail is sent but without the attachment. For some strange reason, I can also no longer find any information on the attachments hook. Has that feature been removed from Formit recently?
[[!FormIt?
&hooks=`spam,email,attachments,redirect`
&emailTpl=`sometemplate`
&emailTo=`foo#foo.com`
&emailBCC=`foo2#foo.com`
&emailSubject=`some subject`
&redirectTo=`123`
&validate=`name:required, filedata:required`
]]
<form action="[[~[[*id]]]]" method="post" class="form" enctype="multipart/form-data">
<input type="text" name="name" id="name" value="[[!+fi.name]]">
<input id="filedata" name="filedata" type="file" value="[[+fi.filedata]]">
<button type="submit">SEND</button>
</form>
Again, mail is sent (I tried many different email adresses) but the attachment is always missing. What's wrong?

Did you try https://modx.com/extras/package/ajaxupload2 extra?
From description:
With two FormIt hooks the upload queue could be pre filled from a FormIt field
value and be saved into a FormIt field value. With a third FormIt hook the
uploaded files could be attached to the FormIt mails.

Just leave the hook 'attachements' away, formit handles a file input without that hook.

Related

How to get last inserted ID and send again

How can I send the lastInsertId again to another php document?
Explanation why:
After someone sends a form (form.html) to a database (send.php) he will get an ID for that form. This ID I show in the send.php to the person via PDO:
<p>Your ID:<?php echo $dbh->lastInsertId(); ?></p>
At this confirmation page I want give the person the possibility to print the data from his form as an pdf. So I wrote:
<form action="print.php" method="POST">
<input type="hidden" name="ID" value="<=htmlspecialchars($_POST['lastInsertId']);?>"/>
<input type="submit" name="Print" value="Print" >
</form>
But I he doesn't send the lastInsertId -> I guess the problem is here:
value="<?=htmlspecialchars($_POST['lastInsertId']);?>"
Can you help me to solve that problem?
Your code should be like this:
<form action="print.php" method="POST">
<input type="hidden" name="ID" value="<?php echo $dbh->lastInsertId(); ?>"/>
<input type="submit" name="Print" value="Print" >
</form>
Not sure if it's the best way, but I once needed the last ID of a person who registered.
I did the following after inserting the info into the DB (My table has Auto Increment Primairy Key ID):
$lastId = mysqli_insert_id($con);
You can store the ID anywhere you want. (In the URL or cookie)
Hope this helps (:
Thank you very much! That helped.
Is their an easy way that after he press print (now gets with the ID all the data from the database to show it at the site print.php - that part all works) and NOW DIRECTLY asks to save as pdf?

PayPal `rm` hidden value not returning POST data

<form action=" https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" id="paypalform" name="paypalform">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="abc#abc.com">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="currency_code" value="<?php echo $currency ?>">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="country" value="US">
<input type="hidden" name="return" value="http://abc-return.com">
<input type="hidden" name="cancel_return" value="http://abc-cancel.com">
<input type="hidden" name="item_name_1" value="Recharge">
<input type="hidden" name="item_number_1" value="<?php echo $user_id ?>">
<input type="hidden" name="amount_1" value="<?php echo $price ?>">
</form>
<script type="text/javascript">document.paypalform.submit();</script>
I'm using PayPal Payments Standard, via the HTML hidden name-value pair.
Payment was working great and smooth as butter until the 9th of this month, when things started getting worse. The return method rm = 2 was returning the post data to my return page before this date, but when I checked on 9th, the post data is not returning to my page.
I've spent more than a week and still can't figure out how could the same code works one day, and not the day afterwards.
I've implemented this method in my many other projects which could get me into trouble if the data is not posting back on my return page. Everything is just fine with my HTML forms, and I'm also receiving the payment on my PayPal Sandbox
The only issue is I'm not getting the post data on my return page.
Please help me resolve this.
Yes, I also confirm this issue. I am not certain if this is a Paypal change or a Paypal error - for it is difficult to find authoritative answers from them.
I also have a form that used to return POST data to the return url - however it recently stopped working and I was able to get it working again using GET method instead by following this helpful article.
However, this will require some changes to your IPN and success pages.
Curious to know how you solved your issue. Please update us.
Thanks for your update, however, I think there's some confusion here. The IPN url is called the notify_URL and that should receive the POSTed data back to verify the transaction. The Thank you page (or success page) is called the return url - which is where your AutoReturn takes you. I have always been receiving the POST data to my IPN page no problem AND the the POST data to my return URL. However, just in the last few weeks, the POST data stopped coming to my success (return) URL but there's no explanation as to why it would suddenly stop. Now, I can only receive GET data at my success/return page by turning on PDT. But it's OK - I re-wrote my thank you page script to use the GET variables instead. PayPal must have change this without there being any notification - very annoyed with them.

Amazon s3 form post/upload redirecting to bucket after success on iOS safari/chrome only how to stop?

I have a web app that allows users to upload photos to an S3 bucket via HTML form. It works exactly as expected on all desktop browsers, which is to do nothing after a successful upload. However in iOS safari and iOS chrome, it redirects to the bucket. If I "Handoff" the page over to safari on my mac it is an xml response of the entire bucket, it appears.
Does anyone know why this would happen and how to fix it? Normally I can find something via google and the forums but I'm finding nothing!
We are not specifying "success action redirect" or "success action status" on our form.
Also, it works as expected in chrome on an android device.
We do not want any sort of redirect to occurs, we handle things on the client after clicking the submit/post button.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<div id ="mainContent">
<form action="https://s3.amazonaws.com/{!awsKeySet.Name}" method="post" enctype="multipart/form-data" id="uploadForm">
<input type="hidden" name="key" id="key" />
<input type="hidden" name="AWSAccessKeyId" value="{!awsKeySet.AWS_AccessKey_Id__c}" />
<input type="hidden" name="policy" value="{!policy}" />
<input type="hidden" name="signature" value="{!signedPolicy}" />
<input type="hidden" name="acl" value="{!acessType}" />
<input type="hidden" name="Content-Type" value="{!Content_Type}" />
<!--input type="hidden" name="success_action_status" value="201" /-->
<!--input type="hidden" name="success_action_redirect" value="{!ForRedirect}" /-->
<h4 class="fileToUpload">Select a File to Upload in AWS</h4><br />
<div class="row">
<input type="file" size="50" name="file" id="file" />
</div>
<div id="fileName"></div>
<div id="fileSize"></div>
<div id="fileType"></div>
<div class="row">
<input type="submit" value="Upload" id="btn_submit" />
</div>
<div id="progressNumber"></div>
</form>
</div>
<script>
$(document).ready(function () {
var _requestBucket;
$("#btn_submit").click(function(event){
//alert(1);
event.preventDefault();
var _file;
_file = $("#file").val().replace(/.+[\\\/]/, "");
console.log('_file '+ _file);
$("#key").val(_file);
$("#uploadForm").submit();
});
});
</script>
Thank you!
I wish someone could have shed more light on this but sadly, this is a bug in iOS webkit browsers. It appears to have been fixed in Android and Desktop. So, if anyone stumbles on this problem, included is the bugzilla link for it
Bugzilla link for Proper handling of HTTP 204
More detail : According to the amazon s3 docs
If the value is set to 200 or 204, Amazon S3 returns an empty document with a
200 or 204 status code.
If the value is set to 201, Amazon S3 returns an XML document with a
201 status code.
If the value is not set or if it is set to an invalid value, Amazon S3
returns an empty document with a 204 status code.
According to HTTP 1.1 -
10.2.5 204 No Content
The server has fulfilled the request but does not need to return an
entity-body, and might want to return updated metainformation. The
response MAY include new or updated metainformation in the form of
entity-headers, which if present SHOULD be associated with the
requested variant.
If the client is a user agent, it SHOULD NOT change its document view
from that which caused the request to be sent. This response is
primarily intended to allow input for actions to take place without
causing a change to the user agent's active document view, although
any new or updated metainformation SHOULD be applied to the document
currently in the user agent's active view.
The 204 response MUST NOT include a message-body, and thus is always
terminated by the first empty line after the header fields.
This is not happening in either webkit browsers for iOS, currently. Sadly. I cannot find a way around this, other for Apple to fix it!

JSoup posting login data

I am attempting to use JSoup for parsing HTML, logging into an account and then parsing additional HTML.
There are several tests I have performed on simple HTML, but I picked a website written in JSP that I have an account on, but I am not having any luck attempting to log into the site..
From the HTML, I have the following fields as part of the input:
input id="loginPopup" type="text" size="25" value="" name="/atg/userprofiling/ProfileFormHandler.value.login" maxlength="46"
input type="hidden" value=" " name="_D:/atg/userprofiling/ProfileFormHandler.value.login"
and
input id="passwordPopup" maxlength="25" name="/atg/userprofiling/ProfileFormHandler.value.password" value="" type="password" autocomplete="off" size="25"
input name="_D:/atg/userprofiling/ProfileFormHandler.value.password" value=" " type="hidden"
After retrieving the HTML, I am executing the following:
doc = Jsoup.connect(MAIN_URL)
.data("/atg/userprofiling/ProfileFormHandler.value.login", "xxxxxx#yahoo.com")
.data("/atg/userprofiling/ProfileFormHandler.value.password", "<password>");
.post();
..actually, I have tried several combinations, but am having no success.. I end up getting the "wrong userid/password" screen...
I have also used JSoup to ensure I have the proper name value by:
Element input = doc.getElementById("loginPopup");
String inputName = input.attr("name");
I have been looking for other JSoup examples, and thought maybe someone here might have some insight...
I will be redirected to a secured (HTTPS) page, but I don't think that is the issue. I am assuming it something to do with the strange "name" values of the HTML inputs..?
Thanks
Use a chrome extension called POSTMAN to try simulate the login, Oracle ATG usually needs more fields to login than just Login and Password, open chrome Developer Tools and check the Network while doing a real login to the site, then you will be able to see all the paramenters needed to simulate the login from code.
[]s

Syntax error with parseJSON during unobtrusive validation

My MVC app is generating the following HTML which causes a Javascript syntax error upon submission (I'm not typing anything into the two text boxes). Here's the generated HTML and the submit handler:
<form action="/UrIntake/Save" id="UrIntakeForm" method="post">
<input data-val="true" data-val-length="The field LastName must be a string with a maximum length of 50." data-val-length-max="50" data-val-required="The LastName field is required." id="FormSubmitter_LastName" name="FormSubmitter.LastName" type="text" value="" />
<input data-val="true" data-val-length="The field FirstName must be a string with a maximum length of 50." data-val-length-max="50" data-val-required="The FirstName field is required." id="FormSubmitter_FirstName" name="FormSubmitter.FirstName" type="text" value="" />
<div id="SubmissionButtons" class="right">
<input type="button" onclick="SubmitForm()" value="Submit" />
<input type="button" onclick="CancelForm()" value="Cancel" />
</div>
</form>
function SubmitForm() {
$("#UrIntakeForm").valid();
.
.
.
This is the jQuery code where the syntax error is occurring (v1.9.0). "data" is undefined and the "return" line is where the error occurs:
parseJSON: function( data ) {
// Attempt to parse using the native JSON parser first
if ( window.JSON && window.JSON.parse ) {
return window.JSON.parse( data );
}
Presumably, I don't have to enter anything into the text boxes (and should then get the "field is required" message). Is this what's causing the error? That doesn't make sense, but I don't see what else it could be.
Cause
This is an issue with jquery.validate.unobtrusive.js in your ASP.NET.MVC package.
As of jQuery 1.9, the behavior of parseJSON() has changed and an undefined value would be considered a malformed JSON, resulting in the error you've specified. See the jQuery 1.9 Core Upgrade Guide for more information.
Solution
Use the jQuery Migrate plugin, which among other things adds backward-compatibility to the jQuery parseJSON() utility.
EDIT
According to the official announcement in this thread on Microsoft Connect, the issue has been resolved in the latest release of the framework.
Naturally, as Andreas Larsen noted in the comments, make sure to clear any relevant cache, server-side and client-side, after upgrading to the new release.
I also had this issue. The problem was that $.parseJSON(undefined) causes an exception to be thrown, and that the unobtrusive validation was making that call. As stated in the accepted answer, this has since been fixed.
You can download the Microsoft version of this script which will properly validate without causing an exception from this link: http://ajax.aspnetcdn.com/ajax/mvc/5.1/jquery.validate.unobtrusive.min.js

Resources