32 $zip->addFromString("$event_title/index.php", "<?php\n// Permanent redirection\n\nheader(\"HTTP/1.1 301 Moved Permanently\");\nheader(\"Location: client.php\");\nexit();"); |
32 $zip->addFromString("$event_title/index.php", "<?php\n// Permanent redirection\n\nheader(\"HTTP/1.1 301 Moved Permanently\");\nheader(\"Location: client.php\");\nexit();"); |
33 |
33 |
34 $zip->addEmptyDir("$event_title/images"); |
34 $zip->addEmptyDir("$event_title/images"); |
35 foreach ($files as $key => $file_desc) { |
35 foreach ($files as $key => $file_desc) { |
36 if($file_desc['size']>0) { |
36 if($file_desc['size']>0) { |
37 $zip->addFile($file_desc['tmp_name'], "$event_title/images/".$file_desc['name']); |
37 $zip->addFile($file_desc['tmp_name'], "$event_title/images/".sanitize_filename($file_desc['name'])); |
38 } |
38 } |
39 } |
39 } |
40 |
40 |
41 return $zip->close(); |
41 return $zip->close(); |
42 } |
42 } |
43 |
43 |
44 /** |
|
45 * Modifies a string to remove all non ASCII characters and spaces. |
|
46 */ |
|
47 function slugify($text) |
|
48 { |
|
49 // replace non letter or digits by - |
|
50 $text = preg_replace('~[^\\pL\d]+~u', '-', $text); |
|
51 |
|
52 // trim |
|
53 $text = trim($text, '-'); |
|
54 |
|
55 // transliterate |
|
56 if (function_exists('iconv')) |
|
57 { |
|
58 $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); |
|
59 } |
|
60 |
|
61 // lowercase |
|
62 $text = strtolower($text); |
|
63 |
|
64 // remove unwanted characters |
|
65 $text = preg_replace('~[^-\w]+~', '', $text); |
|
66 |
|
67 if (empty($text)) |
|
68 { |
|
69 return 'n-a'; |
|
70 } |
|
71 |
|
72 return $text; |
|
73 } |
|
74 |
44 |
75 ?> |
45 ?> |
76 |
46 |
77 <!DOCTYPE html> |
47 <!DOCTYPE html> |
78 <html lang="<?php echo($actual); ?>"> |
48 <html lang="<?php echo($actual); ?>"> |
148 print "<div class=\"error-message\"><h2>".$translate->_("Event_error_empty_title")."</h2></div>"; |
118 print "<div class=\"error-message\"><h2>".$translate->_("Event_error_empty_title")."</h2></div>"; |
149 exit; |
119 exit; |
150 } |
120 } |
151 |
121 |
152 foreach ($_FILES as $key => $value) { |
122 foreach ($_FILES as $key => $value) { |
153 $config_values[$key] = "images/".basename($value['name']); |
123 $config_values[$key] = "images/".sanitize_filename(basename($value['name'])); |
154 } |
124 } |
155 |
125 |
156 $event_title = slugify($config_values['title']); |
126 $event_title = slugify($config_values['title']); |
157 |
127 |
158 $zip_filename = "$C_event_props/$event_title.zip"; |
128 $zip_filename = "$C_event_props/$event_title.zip"; |