Browse Source

fix bug-prone php short tags, fix event tag array, and use both country name and code correctly

fix-community-people-mobile
Max Mehl 4 months ago
parent
commit
4e5445445f
Signed by: max.mehl <max.mehl@fsfe.org> GPG Key ID: 2704E4AB371E2E92

+ 3
- 8
cgi-bin/registerevent.php View File

@@ -52,12 +52,6 @@ function eval_date($date) {
52 52
 	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);
53 53
 }
54 54
 
55
-if (isset($_POST['tags'])) {
56
-  $tags = $_POST['tags'];
57
-} else {
58
-  $tags = array();
59
-}
60
-
61 55
 function send_registration_mail($from, $to) {
62 56
 	$data = array(
63 57
 		'name' => $_POST['name'],
@@ -71,8 +65,9 @@ function send_registration_mail($from, $to) {
71 65
 		'url' => htmlspecialchars($_POST['url']),
72 66
 		'location' => $_POST['location'],
73 67
 		'city' => $_POST['city'],
74
-		'country' => $_POST['country'],
75
-		'tags' => $tags,
68
+		'countrycode' => explode('|', $_POST['country'])[0],
69
+		'countryname' => explode('|', $_POST['country'])[1],
70
+		'tags' => $_POST['tags']
76 71
 	);
77 72
 
78 73
 	$data['event'] = eval_template('registerevent/event.php', $data);

+ 30
- 28
community/tools/eventregistration.en.xhtml View File

@@ -79,34 +79,36 @@
79 79
         <div class="form-group">
80 80
         <label for="country">Country<span class="star">*</span></label>        
81 81
         <select name="country" class="form-control">
82
-			<option value="at">Austria</option>
83
-			<option value="be">Belgium</option>
84
-			<option value="bg">Bulgaria</option>
85
-			<option value="hr">Croatia</option>
86
-			<option value="dk">Denmark</option>
87
-			<option value="ee">Estonia</option>
88
-			<option value="fi">Finland</option>
89
-			<option value="fr">France</option>
90
-			<option value="de">Germany</option>
91
-			<option value="gr">Greece</option>
92
-			<option value="hu">Hungary</option>
93
-			<option value="ie">Ireland</option>
94
-			<option value="it">Italy</option>
95
-			<option value="lv">Latvia</option>
96
-			<option value="lt">Lithuania</option>
97
-			<option value="lu">Luxembourg</option>
98
-			<option value="mt">Malta</option>
99
-			<option value="nl">Netherlands</option>
100
-			<option value="pl">Poland</option>
101
-			<option value="pt">Portugal</option>
102
-			<option value="ro">Romania</option>
103
-			<option value="sk">Slovakia</option>
104
-			<option value="si">Slovenia</option>
105
-			<option value="es">Spain</option>
106
-			<option value="se">Sweden</option>
107
-			<option value="uk">United Kingdom</option>
108
-			<option value="other">Other</option>
109
-		</select>
82
+          <option value="at|Austria">Austria</option>
83
+          <option value="be|Belgium">Belgium</option>
84
+          <option value="bg|Bulgaria">Bulgaria</option>
85
+          <option value="hr|Croatia">Croatia</option>
86
+          <option value="dk|Denmark">Denmark</option>
87
+          <option value="ee|Estonia">Estonia</option>
88
+          <option value="fi|Finland">Finland</option>
89
+          <option value="fr|France">France</option>
90
+          <option value="de|Germany">Germany</option>
91
+          <option value="gr|Greece">Greece</option>
92
+          <option value="hu|Hungary">Hungary</option>
93
+          <option value="ie|Ireland">Ireland</option>
94
+          <option value="it|Italy">Italy</option>
95
+          <option value="lv|Latvia">Latvia</option>
96
+          <option value="lt|Lithuania">Lithuania</option>
97
+          <option value="lu|Luxembourg">Luxembourg</option>
98
+          <option value="mt|Malta">Malta</option>
99
+          <option value="nl|Netherlands">Netherlands</option>
100
+          <option value="pl|Poland">Poland</option>
101
+          <option value="pt|Portugal">Portugal</option>
102
+          <option value="ro|Romania">Romania</option>
103
+          <option value="sr|Serbia">Serbia</option>
104
+          <option value="sk|Slovakia">Slovakia</option>
105
+          <option value="si|Slovenia">Slovenia</option>
106
+          <option value="es|Spain">Spain</option>
107
+          <option value="se|Sweden">Sweden</option>
108
+          <option value="ch|Switzerland">Switzerland</option>
109
+          <option value="uk|United Kingdom">United Kingdom</option>
110
+          <option value="other|outside of Europe">Other</option>
111
+        </select>
110 112
 		</div>
111 113
 
112 114
         <!--</fieldset>-->

+ 22
- 24
templates/registerevent/event.php View File

@@ -1,28 +1,26 @@
1
-<?='<?xml version="1.0" encoding="utf-8"?>'?>
1
+<?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?>
2 2
 
3
+<eventset>
4
+  <event start="<?php echo htmlspecialchars($startdate) ?>" end="<?php if($enddate) { echo htmlspecialchars($enddate); } else { echo htmlspecialchars($startdate); }?>">
3 5
 
4
-<eventset> 
5
-	<event start="<?=htmlspecialchars($startdate)?>" end="<?if($enddate):?><?=htmlspecialchars($enddate)?><?else:?><?=htmlspecialchars($startdate)?><?endif;?>"> 
6
- 
7
-		<title><?if($title):?><?=htmlspecialchars($title)?><?else:?>FSFE event<?endif;?><?if($city):?> in <?=htmlspecialchars($city)?><?endif;?><?if($country):?>, <?=htmlspecialchars($country)?><?endif;?></title> 
8
- 
9
-		<body> 
10
-			<p><?=$description?></p> 
11
-		</body><?if($url):?> 
12
- 
13
-		<link><?=htmlspecialchars($url)?></link><?endif;?> 
14
- 
6
+    <title><?php echo htmlspecialchars($title) . " in " . htmlspecialchars($city) . ", " . htmlspecialchars($countryname); ?></title>
15 7
 
16
-		<tags>
17
-			<tag content=""><?=htmlspecialchars($country)?></tag>
18
-			<?php
19
-				foreach ($tags as $tag) {
20
-					echo sprintf('<tag content="">%s</tag>', htmlspecialchars($tag));
21
-				}
22
-			?>
23
-			<tag>front-page</tag>
24
-		</tags>
8
+    <body>
9
+      <p><?php echo $description?></p>
10
+    </body>
25 11
 
26
- 
27
-	</event> 
28
-</eventset> 
12
+    <?php if($url) { echo "<link>" . htmlspecialchars($url) . "</link>"; }?>
13
+
14
+    <tags>
15
+      <tag content=""><?php echo htmlspecialchars($countrycode); ?></tag>
16
+      <?php
17
+        foreach ($tags as $tag) {
18
+          echo sprintf('<tag content="">%s</tag>', htmlspecialchars($tag)) . "\n";
19
+        }
20
+      ?>
21
+      <tag>front-page</tag>
22
+    </tags>
23
+
24
+
25
+  </event>
26
+</eventset>

+ 1
- 1
templates/registerevent/mail.php View File

@@ -13,7 +13,7 @@ Below is the list of the information you gave.
13 13
 	Name: <?=$name?> 
14 14
 	Email: <?=$email?> 
15 15
 
16
-	Location: <?=$city?>, <?=$country?>
16
+	Location: <?=$city?>, <?=$countryname?>
17 17
  
18 18
 You find all other information in the xml file attached. It will be uploaded
19 19
 in the next 24 hours. If you like to withdraw your event or in case you like to change some information,

+ 1
- 1
templates/registerevent/wiki.php View File

@@ -4,7 +4,7 @@
4 4
 = <?=$title?> =
5 5
  Start:: <?=$startdate?> 
6 6
  End:: <?=$enddate?> 
7
- Location:: <?=$city?>, <?=$country?> 
7
+ Location:: <?=$city?>, <?=$countryname?> 
8 8
  Link:: <?=$url?> 
9 9
  bgcolor:: #FFFFFF
10 10
  Description:: <?=$description?> 

Loading…
Cancel
Save