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.

registerevent.php 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /* Copyright (C) 2012, Tobias Bengfort <tobias.bengfort@gmx.net> & Marius Jammes for FSFE e.V.
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. function eval_xml_template($template, $data) {
  14. $dir = realpath(dirname(__FILE__) . '/../templates');
  15. $result = file_get_contents("$dir/$template");
  16. foreach ($data as $key => $value)
  17. $result = preg_replace("/<tpl name=\"$key\"><\/tpl>/", $value, $result);
  18. $result = preg_replace("/<tpl name=\"[^\"]*\"><\/tpl>/", '', $result);
  19. return $result;
  20. }
  21. function eval_template($template, $data) {
  22. extract($data);
  23. $dir = realpath(dirname(__FILE__) . '/../templates');
  24. ob_start();
  25. include("$dir/$template");
  26. $result = ob_get_contents();
  27. ob_end_clean();
  28. return $result;
  29. }
  30. // deleted resize image
  31. function get_mime_type($path) {
  32. if ( function_exists('finfo_open') ) {
  33. $finfo = finfo_open(FILEINFO_MIME_TYPE);
  34. $mime = finfo_file($finfo, $path);
  35. finfo_close($finfo);
  36. return $mime;
  37. }
  38. else
  39. return mime_content_type($path);
  40. }
  41. //removed partner img function
  42. function eval_date($date) {
  43. $dt = date_parse($date);
  44. return (!$dt['errors'] && $dt['year'] && preg_match("#^(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$#", $date) === 1);
  45. }
  46. if (isset($_POST['tags'])) {
  47. $tags = $_POST['tags'];
  48. } else {
  49. $tags = array();
  50. }
  51. function send_registration_mail($from, $to) {
  52. $data = array(
  53. 'name' => $_POST['name'],
  54. 'email' => $_POST['email'],
  55. 'title' => $_POST['title'],
  56. 'groupname' => $_POST['groupname'],
  57. 'groupurl' => $_POST['groupurl'],
  58. 'startdate' => $_POST['startdate'],
  59. 'enddate' => $_POST['enddate'],
  60. 'description' => $_POST['description'],
  61. 'url' => htmlspecialchars($_POST['url']),
  62. 'location' => $_POST['location'],
  63. 'city' => $_POST['city'],
  64. 'country' => $_POST['country'],
  65. 'tags' => $tags,
  66. );
  67. $data['event'] = eval_template('registerevent/event.php', $data);
  68. $data['wiki'] = eval_template('registerevent/wiki.php', $data);
  69. $message = eval_template('registerevent/mail.php', $data);
  70. $subject = "Event registration: " . $_POST['title'];
  71. $headers = "From: " . $from . "\n"
  72. . "MIME-Version: 1.0\n"
  73. . "X-OTRS-Queue: Misc\n"
  74. . "X-OTRS-Owner: eal\n"
  75. . "X-OTRS-Responsible: eal\n"
  76. . "Content-Type: multipart/mixed; boundary=boundary";
  77. mail($to, $subject, $message, $headers);
  78. return $data['img_error'];
  79. }
  80. if ( isset($_POST['register_event']) AND empty($_POST['spam']) AND eval_date($_POST['startdate']) AND eval_date($_POST['enddate']) || empty($_POST['enddate']) ) {
  81. $error = send_registration_mail($_POST['name'] . " <" . $_POST['email'] . ">", "FSFE <contact@fsfe.org>");
  82. $error = send_registration_mail("FSFE <contact@fsfe.org>", $_POST['name'] . " <" . $_POST['email'] . ">");
  83. echo eval_xml_template('registerevent/success.en.html', array(
  84. 'notice' => '', // TODO display some error code here
  85. ));
  86. }
  87. else {
  88. echo eval_xml_template('registerevent/error.en.html', array(
  89. 'notice' => '', // TODO display the error here
  90. ));
  91. }
  92. ?>