STW: ability to subscribe to community mails (#760)
All checks were successful
the build was successful
All checks were successful
the build was successful
This commit is contained in:
parent
b7f44d57b1
commit
9ea8901777
60
cgi-bin/mail-signup.php
Normal file
60
cgi-bin/mail-signup.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
// This script signs up an email address with other (partly optional) data
|
||||
// to the community database (occasional emails) and the newsletter
|
||||
|
||||
// Available POST params: list, mail, name, language, address, zip, city, country
|
||||
|
||||
$list = isset($_POST['list']) ? $_POST['list'] : false;
|
||||
$mail = isset($_POST['mail']) ? $_POST['mail'] : false;
|
||||
$name = isset($_POST['name']) ? $_POST['name'] : false;
|
||||
$language = isset($_POST['language']) ? $_POST['language'] : false;
|
||||
$address = isset($_POST['address']) ? $_POST['address'] : false;
|
||||
$zip = isset($_POST['zip']) ? $_POST['zip'] : false;
|
||||
$city = isset($_POST['city']) ? $_POST['city'] : false;
|
||||
$country = isset($_POST['country']) ? $_POST['country'] : false;
|
||||
|
||||
# Check required variables
|
||||
if (empty($list) ||
|
||||
empty($mail) ) {
|
||||
echo "Missing parameters. Required: list, mail";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ($list == 'community' ) {
|
||||
# "name" is also required for Community Database
|
||||
if (empty($name)) {
|
||||
echo "Missing parameters. Required: name";
|
||||
exit(1);
|
||||
}
|
||||
$signupdata = array(
|
||||
'name' => $name,
|
||||
'email1' => $mail,
|
||||
'address' => $address,
|
||||
'zip' => $zip,
|
||||
'city' => $city,
|
||||
'country' => $country
|
||||
);
|
||||
print_r($signupdata);
|
||||
mail_signup('https://my.fsfe.org/subscribe', $signupdata);
|
||||
} elseif ($list == 'newsletter') {
|
||||
echo "";
|
||||
} else {
|
||||
echo "List to sign up email to is unknown. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
function mail_signup($url, $data) {
|
||||
$context = stream_context_create(
|
||||
array(
|
||||
'http' => array(
|
||||
'method' => 'POST',
|
||||
'header' => 'Content-type: application/x-www-form-urlencoded',
|
||||
'content' => http_build_query($data),
|
||||
'timeout' => 10
|
||||
)
|
||||
)
|
||||
);
|
||||
file_get_contents($url, FALSE, $context);
|
||||
}
|
||||
|
||||
?>
|
@ -111,6 +111,22 @@ function send_mail ( $to, $from, $subject, $msg, $bcc = NULL, $att = NULL, $att_
|
||||
return mail( $to, $subject, $message, $headers );
|
||||
}
|
||||
|
||||
# send information to mail-signup.php if user wished to sign up to community mails or newsletter
|
||||
function mail_signup($data) {
|
||||
$url = $_SERVER['REQUEST_SCHEME']. '://' . $_SERVER['HTTP_HOST'] . '/cgi-bin/mail-signup.php';
|
||||
$context = stream_context_create(
|
||||
array(
|
||||
'http' => array(
|
||||
'method' => 'POST',
|
||||
'header' => 'Content-type: application/x-www-form-urlencoded',
|
||||
'content' => http_build_query($data),
|
||||
'timeout' => 10
|
||||
)
|
||||
)
|
||||
);
|
||||
file_get_contents($url, FALSE, $context);
|
||||
}
|
||||
|
||||
$lang = $_POST['language'];
|
||||
|
||||
# Sanity checks (*very* sloppy input validation)
|
||||
@ -196,6 +212,20 @@ $name = escapeshellarg($name);
|
||||
$address = escapeshellarg($address);
|
||||
shell_exec("$odtfill $template $outfile Name=$name Address=$address Name=$name");
|
||||
|
||||
# Make subscriptions to newsletter/community mails
|
||||
if ($_POST['subcd'] == "y") {
|
||||
$signupdata = array(
|
||||
'list' => 'community',
|
||||
'name' => $_POST['firstname'] . " " . $_POST['lastname'],
|
||||
'mail' => $_POST['mail'],
|
||||
'address' => $_POST['street'],
|
||||
'zip' => $_POST['zip'],
|
||||
'city' => $_POST['city'],
|
||||
'country' => $countrycode
|
||||
);
|
||||
mail_signup($signupdata);
|
||||
}
|
||||
|
||||
$test = send_mail ("contact@fsfe.org", $_POST['firstname'] . " " . $_POST['lastname'] . " <" . $_POST['mail'] . ">", $subject, $msg, NULL, file_get_contents($outfile), "application/vnd.oasis.opendocument.text", "letter.odt");
|
||||
|
||||
if (isset($_POST['donate']) && ($_POST['donate'] > 0)) {
|
||||
|
@ -237,11 +237,10 @@
|
||||
<div>
|
||||
<input type="text" name="address" placeholder="Which address shall be used?" size="20" class="special" />
|
||||
</div>
|
||||
<!-- hide newsletter field for once as it requires some extra backend work
|
||||
<div>
|
||||
<span class="formlabel">Receive the latest Free Software news:</span>
|
||||
<label for="wantinfo"><input name="wantinfo" id="wantinfo" type="checkbox" />I want to receive occasional information about FSFE's activities (less than one email a week on average)</label>
|
||||
</div> -->
|
||||
<label for="subcd"><input name="subcd" id="subcd" value="y" type="checkbox" />I want to receive occasional information about the FSFE's activities</label>
|
||||
</div>
|
||||
<div>
|
||||
<span class="formlabel">Support our work with a voluntary donation*:</span>
|
||||
<input type="number" name="donate" value="" min="0" step="5" placeholder="0 or ≥ 10 €" required="required" />€
|
||||
|
@ -241,7 +241,7 @@
|
||||
<xsl:attribute name="type">hidden</xsl:attribute>
|
||||
<xsl:attribute name="name">language</xsl:attribute>
|
||||
<xsl:attribute name="value">
|
||||
<xsl:value-of select="/buildinfo/document/@language" />
|
||||
<xsl:value-of select="/buildinfo/@language" />
|
||||
</xsl:attribute>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
Loading…
x
Reference in New Issue
Block a user