5 Jappix - An open social platform
6 This is the design configuration POST handler (manager)
8 -------------------------------------------------
12 Last revision: 25/08/11
16 // Someone is trying to hack us?
17 if(!defined('JAPPIX_BASE'))
20 // Handle the remove GET
21 if(isset($_GET['k']) && !empty($_GET['k'])) {
22 $kill_logo = JAPPIX_BASE.'/store/logos/'.$_GET['k'].'.png';
24 if(isSafe($kill_logo) && file_exists($kill_logo)) {
27 echo('<p class="info smallspace success">'.T_("The selected elements have been removed.").'</p>');
31 // Handle the remove POST
32 else if(isset($_POST['remove']))
35 // Handle the logo upload POST
36 else if(isset($_POST['logo_upload'])) {
38 $logos_arr_1_name = $logos_arr_1_tmp = $logos_arr_2_name = $logos_arr_2_tmp = $logos_arr_3_name = $logos_arr_3_tmp = $logos_arr_4_name = $logos_arr_4_tmp = '';
40 if(isset($_FILES['logo_own_1_location'])) {
41 $logos_arr_1_name = $_FILES['logo_own_1_location']['name'];
42 $logos_arr_1_tmp = $_FILES['logo_own_1_location']['tmp_name'];
45 if(isset($_FILES['logo_own_2_location'])) {
46 $logos_arr_2_name = $_FILES['logo_own_2_location']['name'];
47 $logos_arr_2_tmp = $_FILES['logo_own_2_location']['tmp_name'];
50 if(isset($_FILES['logo_own_3_location'])) {
51 $logos_arr_3_name = $_FILES['logo_own_3_location']['name'];
52 $logos_arr_3_tmp = $_FILES['logo_own_3_location']['tmp_name'];
55 if(isset($_FILES['logo_own_4_location'])) {
56 $logos_arr_4_name = $_FILES['logo_own_4_location']['name'];
57 $logos_arr_4_tmp = $_FILES['logo_own_4_location']['tmp_name'];
62 array($logos_arr_1_name, $logos_arr_1_tmp, JAPPIX_BASE.'/store/logos/desktop_home.png'),
63 array($logos_arr_2_name, $logos_arr_2_tmp, JAPPIX_BASE.'/store/logos/desktop_app.png'),
64 array($logos_arr_3_name, $logos_arr_3_tmp, JAPPIX_BASE.'/store/logos/mobile.png'),
65 array($logos_arr_4_name, $logos_arr_4_tmp, JAPPIX_BASE.'/store/logos/mini.png')
70 $logo_not_png = false;
71 $logo_anything = false;
73 foreach($logos as $sub_array) {
75 if(!$sub_array[0] || !$sub_array[1])
79 if(getFileExt($sub_array[0]) != 'png') {
86 if(!move_uploaded_file($sub_array[1], $sub_array[2])) {
92 $logo_anything = true;
96 if($logo_not_png) { ?>
97 <p class="info smallspace fail"><?php _e("This is not a valid image, please use the PNG format!"); ?></p>
101 else if($logo_error || !$logo_anything) { ?>
102 <p class="info smallspace fail"><?php _e("The image could not be received, would you mind retry?"); ?></p>
105 // Everything went fine
107 <p class="info smallspace success"><?php _e("Your service logo has been successfully changed!"); ?></p>
111 // Handle the background upload POST
112 else if(isset($_POST['background_upload'])) {
114 $name_background_image = $_FILES['background_image_upload']['name'];
115 $temp_background_image = $_FILES['background_image_upload']['tmp_name'];
116 $path_background_image = JAPPIX_BASE.'/store/backgrounds/'.$name_background_image;
119 if(!isSafe($name_background_image) || $_FILES['background_image_upload']['error'] || !move_uploaded_file($temp_background_image, $path_background_image)) { ?>
121 <p class="info smallspace fail"><?php _e("The image could not be received, would you mind retry?"); ?></p>
126 else if(!isImage($name_background_image)) {
127 // Remove the image file
128 if(file_exists($path_background_image))
129 unlink($path_background_image);
132 <p class="info smallspace fail"><?php _e("This is not a valid image, please use PNG, GIF or JPG!"); ?></p>
136 // The file has been sent
139 <p class="info smallspace success"><?php _e("Your image was added to the list!"); ?></p>
144 // Handle the save POST
145 else if(isset($_POST['save'])) {
149 // Handle it for background
150 $background = array();
152 if(isset($_POST['background_type']))
153 $background['type'] = $_POST['background_type'];
155 if(isset($_POST['background_image_file']))
156 $background['image_file'] = $_POST['background_image_file'];
158 if(isset($_POST['background_image_repeat']))
159 $background['image_repeat'] = $_POST['background_image_repeat'];
161 if(isset($_POST['background_image_horizontal']))
162 $background['image_horizontal'] = $_POST['background_image_horizontal'];
164 if(isset($_POST['background_image_vertical']))
165 $background['image_vertical'] = $_POST['background_image_vertical'];
167 if(isset($_POST['background_image_adapt']))
168 $background['image_adapt'] = 'on';
170 if(isset($_POST['background_image_color']))
171 $background['image_color'] = $_POST['background_image_color'];
173 if(isset($_POST['background_color_color']))
174 $background['color_color'] = $_POST['background_color_color'];
176 // Write the configuration file
177 writeBackground($background);
179 // Handle it for notice
180 if(isset($_POST['notice_type']))
181 $notice_type = $_POST['notice_type'];
183 $notice_type = 'none';
187 if(isset($_POST['notice_text']))
188 $notice_text = $_POST['notice_text'];
191 if(!$notice_text && ($notice_type != 'none'))
192 $save_marker = false;
196 // Write the notice configuration
197 writeNotice($notice_type, $notice_text);
199 // Show a success notice
202 <p class="info smallspace success"><?php _e("Your design preferences have been saved!"); ?></p>
206 // Something went wrong
209 <p class="info smallspace fail"><?php _e("Please check your inputs: something is missing!"); ?></p>