Source files of fsfe.org, pdfreaders.org, freeyourandroid.org, ilovefs.org, drm.info, and test.fsfe.org. Contribute: https://fsfe.org/contribute/web/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mail-signup.php 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. // This script signs up an email address with other (partly optional) data
  3. // to the community database (occasional emails) and the newsletter
  4. // Available POST params: list, mail, name, language, address, zip, city, country
  5. $list = isset($_POST['list']) ? $_POST['list'] : false;
  6. $mail = isset($_POST['mail']) ? $_POST['mail'] : false;
  7. $name = isset($_POST['name']) ? $_POST['name'] : false;
  8. $language = isset($_POST['language']) ? $_POST['language'] : false;
  9. $address = isset($_POST['address']) ? $_POST['address'] : false;
  10. $zip = isset($_POST['zip']) ? $_POST['zip'] : false;
  11. $city = isset($_POST['city']) ? $_POST['city'] : false;
  12. $country = isset($_POST['country']) ? $_POST['country'] : false;
  13. # Check required variables
  14. if (empty($list) ||
  15. empty($mail) ) {
  16. echo "Missing parameters. Required: list, mail";
  17. exit(1);
  18. }
  19. if ($list == 'community' ) {
  20. # "name" is also required for Community Database
  21. if (empty($name)) {
  22. echo "Missing parameters. Required: name";
  23. exit(1);
  24. }
  25. $signupdata = array(
  26. 'name' => $name,
  27. 'email1' => $mail,
  28. 'address' => $address,
  29. 'zip' => $zip,
  30. 'city' => $city,
  31. 'country' => $country
  32. );
  33. print_r($signupdata);
  34. mail_signup('https://my.fsfe.org/subscribe', $signupdata);
  35. } elseif ($list == 'newsletter') {
  36. echo "";
  37. } else {
  38. echo "List to sign up email to is unknown. Exiting.";
  39. exit(1);
  40. }
  41. function mail_signup($url, $data) {
  42. $context = stream_context_create(
  43. array(
  44. 'http' => array(
  45. 'method' => 'POST',
  46. 'header' => 'Content-type: application/x-www-form-urlencoded',
  47. 'content' => http_build_query($data),
  48. 'timeout' => 10
  49. )
  50. )
  51. );
  52. file_get_contents($url, FALSE, $context);
  53. }
  54. ?>