· 8 years ago · Nov 28, 2017, 05:32 PM
1<?php
2/*
3+ ----------------------------------------------------------------------------+
4|
5| Author: OFFBEAT
6| Description: KZ.Random submit maps page
7| Made for: wwww.kz-random.net
8| Date: 2013-07-26
9| Last update: 2013-09-12
10|
11| To do:
12| Nothing for now, maybe need to fix stuff later, but leave it atm.
13|
14| Copyright (C) 2013 OFFBEAT (kz-scandinavia.com)
15|
16+----------------------------------------------------------------------------+
17*/
18
19 require_once( "class2.php" );
20 require_once( "submit_classes.php" );
21
22 define( "e_PAGETITLE", "Submit maps" );
23 define( "MAX_MEGABYTES", 15 );
24
25 require_once( HEADERF );
26
27 if( !USER )
28 $text = "<p>You need to be logged in to submit maps.</p>";
29 else
30 {
31 // Kilobytes and megabytes conversions from bytes
32 // 1 kb = 1024 bytes
33 // 1 mb = 1024 kb ( ( 1 kb * 1024 bytes ) * 1024 bytes )
34 $bytes = 1024;
35 $megabytes = $bytes * $bytes;
36 // Max size of the map archive in bytes form
37 $max_map_size = MAX_MEGABYTES * $megabytes;
38
39 // Define the folders to use for easier and faster access in the code
40 $maps_folder = "download/2man_maps";
41 $maps_submitted = "maps_submitted";
42 // Define the default note in map notes dash bordered paragraph under the form
43 $map_notes = "The map archive can't be bigger than <b>". MAX_MEGABYTES ." MB</b> in size, if it's bigger or you can't submit the map contact a highly positioned admin for help.";
44 // Will handle the submitted status from database, do not hard code numbers, use these values
45 $map_status = array( "pending"=>0, "accepted"=>1, "denied"=>2 );
46
47 // Amount of maps that has been accepted
48 $num_maps_accepted = 0;
49 // Amount of maps that has been submitted through this form
50 $num_maps_total = 0;
51 // Are there any submissions? Get this value and handle stuff later in the code
52 $bool_maps_submitted = false;
53 // Define a basic database variable instead of creating alot of new ones
54 $database = new db;
55 // Define a submission handler
56 $sub_handle = new map_submission;
57
58 /*
59 Get the list of maps in the submitted folder to an array
60 - Update: use database instead
61 function get_uploaded_maps( )
62 {
63 global $maps_temp;
64 $maps = scandir( $maps_temp );
65 sort( $maps );
66
67 // Slice of . and .. (back folders)
68 return array_slice( $maps, 2, ( count( $maps ) - 2 ) );
69 }
70 */
71
72 // Get the submitted map's current status and set status that is matched in database (used in submit-maps-list area)
73 function get_map_status( $status )
74 {
75 // Uee the global map statuses for more correct handle of the numbers
76 global $map_status;
77
78 switch( $status )
79 {
80 case $map_status['accepted']: // Accepted
81 {
82 $set_status = array( "color"=>"green", "status"=>"Accepted" );
83 break;
84 }
85 case $map_status['denied']: // Denied
86 {
87 $set_status = array( "color"=>"red", "status"=>"Denied" );
88 break;
89 }
90 case $map_status['pending']:
91 default: // || > 2: Pending
92 {
93 $set_status = array( "color"=>"orange", "status"=>"Pending" );
94 }
95 }
96
97 return $set_status;
98 }
99
100 // Check if the submitting map is already submitted or existing in the database
101 function map_exists( $map_name )
102 {
103 global $map_status;
104
105 $db = new db;
106 $db->db_Query( "SELECT COUNT( * ) AS `rows` FROM `e107_download` WHERE `download_name` = '{$map_name}'" );
107 $data['exist'] = $db->db_Fetch( MYSQL_ASSOC );
108
109 $db->db_Query( "SELECT COUNT( * ) AS `rows` FROM `2man_submit_maps` WHERE `submitted_map` = '{$map_name}' AND `submitted_status` <> '{$map_status['denied']}'" );
110 $data['submitted'] = $db->db_Fetch( MYSQL_ASSOC );
111
112 // Not FALSE rows (0)
113 if( $data['exist']['rows'] || $data['submitted']['rows'] )
114 return true;
115
116 // Map isn't existing in database or is submitted
117 return false;
118 }
119
120 function user_exists( $user_name )
121 {
122 $db = new db;
123 $db->db_Query( "SELECT COUNT( * ) AS `rows` FROM `e107_user` WHERE `user_name` = '{$user_name}'" );
124 $data = $db->db_Fetch( MYSQL_ASSOC );
125
126 // Not FALSE rows (0)
127 if( $data['rows'] )
128 return true;
129
130 return false;
131 }
132
133 // A submission is about to be made, handle it
134 if( isset( $_POST['submit'] ) )
135 {
136 // Trim user inputet fields to see if it's empty or not
137 $map_author = trim( $_POST['map_author'] );
138 $map_description = trim( $_POST['description'] );
139
140 // Not empty user input fields?
141 if( ( !empty( $map_author ) && !empty( $map_description ) ) || $_FILES['map']['error'] == 4 )
142 {
143 // Make it database friendly, don't trust user inputs
144 $map_author = mysql_real_escape_string( $map_author );
145 $map_description = mysql_real_escape_string( $map_description );
146
147 // If the map upload got errors, handle it
148 if( $_FILES['map']['error'] > 0 )
149 {
150 switch( $_FILES['map']['error'] )
151 {
152 case 3:
153 {
154 $sub_handle->set_status( "The map file was only partially uploaded.", "submit", "red" );
155 break;
156 }
157 case 7:
158 {
159 $sub_handle->set_status( "Failed to write the map file to server.", "submit", "red" );
160 break;
161 }
162 default:
163 {
164 $sub_handle->set_status( "Map submission returned the error code: {$_FILES['map']['error']}.", "submit", "red" );
165 }
166 }
167 }
168 // No error, continue to handle and validate the uploaded map
169 else
170 {
171 // Save submitted file info
172 $sub_handle->sub_save_file_info( $_FILES['map']['name'] );
173 // The filename is valid
174 if( $sub_handle->is_valid_filename( ) )
175 {
176 if( map_exists( $sub_handle->sub_file_name ) )
177 $sub_handle->set_status( "A map with that name already exists in the database.", "submit", "red" );
178 else
179 {
180 // Make sure the archive size is under OR exactly the max file size in bytes
181 if( $_FILES['map']['size'] <= $max_map_size )
182 {
183 // If the submitted folder doesn't exist create it
184 if( !is_dir( $maps_submitted ) )
185 mkdir( $maps_submitted );
186
187 // If the map was successfully moved, do this
188 if( move_uploaded_file( $_FILES['map']['tmp_name'], $maps_submitted."/".$sub_handle->sub_file ) )
189 {
190 // Remove file ending
191 $map_name = $sub_handle->sub_file_name;
192 $map_size = $_FILES['map']['size'];
193
194 // Insert new submission to database
195 $database->db_Query( "
196 INSERT INTO `2man_submit_maps` ( `submitted_map`, `submitted_map_size`, `submitted_map_description`, `submitted_user_name`, `submitted_user_id`, `submitted_map_author`, `submitted_date` )
197 VALUES ( '{$map_name}', '{$map_size}', '{$map_description}', '". USERNAME ."', '". USERID ."', '{$map_author}', '". time( ) ."' )
198 " );
199
200 $sub_handle->set_status( "The map got successfully submitted!", "submit", "green" );
201 }
202 else
203 $sub_handle->set_status( "The map couldn't be transfered to the submitted folder.", "submit", "red" );
204 }
205 else
206 $sub_handle->set_status( "The map archive exceeds the maximum allowed upload size (". MAX_MEGABYTES ." MB).", "submit", "red" );
207 }
208 }
209 }
210 }
211 else
212 $sub_handle->set_status( "All fields has to be filled.", "submit", "red" );
213 }
214
215 // Count total amount of submissions
216 $database->db_Query( "SELECT COUNT( * ) AS `rows` FROM `2man_submit_maps`" );
217 $data = $database->db_Fetch( MYSQL_ASSOC );
218
219 $num_maps_total = $data['rows'];
220 // Exists submissions
221 if( $num_maps_total > 0 )
222 {
223 // Count total amount of accepted submissions
224 $database->db_Query( "SELECT COUNT( * ) AS `rows` FROM `2man_submit_maps` WHERE `submitted_status` = '{$map_status['accepted']}'" );
225 $data = $database->db_Fetch( MYSQL_ASSOC );
226 $num_maps_accepted = $data['rows'];
227 $bool_maps_submitted = true;
228 }
229
230 $text = "
231 <div id='submit-maps-form'>
232 <ul class='dashed-border'>
233 <li>{$num_maps_accepted}/{$num_maps_total} map(s) has been accepted.</li>
234 <li class='submit-form-space'><a href='/page.php?6'>Click here</a> to go to the rules page (map submission rules at the bottom).</li>
235 </ul>
236
237 <form action='". e_SELF ."' method='POST' enctype='multipart/form-data' class='submit-form-space'>
238 <fieldset>
239 <legend>Map upload form</legend>
240 <ul>
241 <li>
242 <label for='map-file' class='label-bold'>Map:</label>
243 <input type='file' id='map-file' name='map' />
244 </li>
245 <li class='submit-form-space'>
246 <label for='author' class='label-bold'>Author:</label>
247 <input type='text' id='author' name='map_author' placeholder='Name of the map author' size='25' />
248 </li>
249 <li class='submit-form-space'>
250 <label for='submit-maps-description' class='label-bold'>Description:</label>
251 <textarea placeholder='Short description of the map' id='submit-maps-description' name='description'></textarea>
252 </li>
253 <li class='submit-form-space'><input type='submit' name='submit' id='submit-maps-submit' value='Submit map' /></li>
254 </ul>
255 </fieldset>
256 </form>
257
258 <p class='dashed-border submit-form-space'><b>Map submission notes:</b><br />";
259
260 $get_status = $sub_handle->get_status( "submit", "message" );
261 if( !empty( $get_status ) )
262 {
263 $text .= sprintf( "<span style='color: %s'>%s</span>", $sub_handle->get_status( "submit", "color" ), $sub_handle->get_status( "submit", "message" ) );
264 }
265 else
266 {
267 $text .= "<span style='color: black'>{$map_notes}</span>";
268 }
269
270 $text .= "
271 </p>
272 </div>
273 <div id='submit-maps-list' class='submit-form-space'". ( !$bool_maps_submitted ? " style='display: none'" : "" ) .">
274 <h3 style='margin: 10px 0'>Submitted maps</h3>";
275
276 // Highly positioned admin? Show the admin side of the submitted maps
277 if( getperms( 0 ) )
278 {
279 // Make sure it's just one get sent
280 $query_string = $_SERVER['QUERY_STRING'];
281 $get = explode( "&", $query_string );
282 $num_get_keys = count( $get );
283 if( $num_get_keys > 1 )
284 $bool_multiple_get = true;
285 else
286 $bool_multiple_get = false;
287
288 // UPDATE an edited submission
289 if( isset( $_POST['update'] ) && !$bool_multiple_get )
290 {
291 // Self explained set, but trim the values from spaces
292 $submitted_map_author = trim( $_POST['submitted_map_author'] );
293 $submitted_map_description = trim( $_POST['submitted_description'] );
294 $submitted_user_name = $_POST['submitted_by'];
295
296 // Make sure they are not empty and the edit=id is set and valid to numeric
297 if( isset( $_GET['edit'] ) && is_numeric( $_GET['edit'] ) && !empty( $submitted_map_author ) && !empty( $submitted_map_description ) )
298 {
299 // Self explained also, but escape quotes from what could be a possible harmful string
300 $submitted_id = $_GET['edit'];
301 $submitted_map_author = mysql_real_escape_string( $submitted_map_author );
302 $submitted_map_description = mysql_real_escape_string( $submitted_map_description );
303 // Check to see if the new submitted by user name is valid and not equal to the old
304 $bool_update_user_name = false;
305
306 $database->db_Query( "SELECT `submitted_map`, `submitted_user_name`, `submitted_user_id` FROM `2man_submit_maps` WHERE `submitted_id` = '{$submitted_id}'" );
307 $data = $database->db_Fetch( MYSQL_ASSOC );
308
309 // Same here, self explained
310 $submitted_map = $data['submitted_map'];
311 $user_name = $data['submitted_user_name'];
312 $user_id = $data['submitted_user_id'];
313
314 // If the user name is being edited
315 if( isset( $_POST['submitted_by'] ) )
316 {
317 // Trim and escape quotes
318 $submitted_user_name = mysql_real_escape_string( trim( $submitted_user_name ) );
319 // Now check if it's empty after trimming
320 if( !empty( $submitted_user_name ) )
321 {
322 // Exists, update the user name
323 if( user_exists( $submitted_user_name ) )
324 $bool_update_user_name = true;
325 }
326 }
327
328 // Do not update the user name, use the old one
329 if( !$bool_update_user_name )
330 {
331 $submitted_user_name = $user_name;
332 $submitted_user_id = $user_id;
333 }
334 // Update it
335 else
336 {
337 // User name was already set if the user existed /\ now get the correct user id
338 $database->db_Query( "SELECT `user_id` FROM `e107_user` WHERE `user_name` = '{$submitted_user_name}'" );
339 $data = $database->db_Fetch( MYSQL_ASSOC );
340 $submitted_user_id = $data['user_id'];
341 }
342
343 // Has any submission fields been edited?
344 if( $sub_handle->is_new_information( $submitted_id, "submitted_map_author", $submitted_map_author ) ||
345 $sub_handle->is_new_information( $submitted_id, "submitted_map_description", $submitted_map_description ) ||
346 $sub_handle->is_new_information( $submitted_id, "submitted_user_name", $submitted_user_name ) )
347 {
348 // Then make a database SET array to provide
349 $db_values = array(
350 "submitted_map_author" =>$submitted_map_author,
351 "submitted_map_description" =>$submitted_map_description,
352 "submitted_user_name" =>$submitted_user_name,
353 "submitted_user_id" =>$submitted_user_id );
354
355 // Update the submission and it's information, use the SET array from above
356 $sub_handle->update_submitted_information( $submitted_id, $db_values );
357 // Show status for the admin
358 $sub_handle->set_status( "The map <strong>{$submitted_map}</strong> has been updated!", "admin", "green" );
359 }
360
361 }
362 else
363 $sub_handle->set_status( "The map has not been updated, all fields has to be filled.", "admin", "red" ); // An empty input
364 }
365
366 // EDIT a submission
367 if( isset( $_GET['edit'] ) && !$bool_multiple_get )
368 {
369 // Convert the get id to submitted id
370 $submitted_id = trim( $_GET['edit'] );
371 // Make sure it's not an empty get and only has numeric value
372 if( is_numeric( $submitted_id ) )
373 {
374 // Select what to use, show all columns to remember them all if u're lost
375 $database->db_Query( "SELECT `submitted_map`, `submitted_map_author`, `submitted_user_name`, `submitted_map_description` FROM `2man_submit_maps` WHERE `submitted_id` = '{$submitted_id}'" );
376 $submitted = $database->db_Fetch( MYSQL_ASSOC );
377 // Prevent HTML and script tags (is from a user)
378 $submitted['submitted_map_author'] = htmlspecialchars( $submitted['submitted_map_author'] );
379 $submitted['submitted_map_description'] = htmlspecialchars( $submitted['submitted_map_description'] );
380 // Make sure the id is from an legit submission, does the map column exist?
381 if( isset( $submitted['submitted_map'] ) )
382 {
383 $text .= "
384 <form action='?edit={$submitted_id}' method='POST' enctype='multipart/form-data' class='submit-form-space submit-form-fieldset' onload='Toggle( \"submision-name\" )'>
385 <fieldset>
386 <legend>Edit submitted information</legend>
387 <ul>
388 <li>
389 <p id='submission-name'><span>{$submitted['submitted_map']}</span></p>
390 </li>
391 <li class='submit-form-space'>
392 <label for='submitted-map-author' class='label-bold label-block'>Map author:</label>
393 <input type='text' id='submitted-map-author' name='submitted_map_author' value='{$submitted['submitted_map_author']}' placeholder='Name of the map author' size='25' />
394 </li>
395 <li class='submit-form-space'>
396 <label for='submitted-by' class='label-bold label-block'>Submitted by:</label>
397 <input type='text' id='submitted-by' name='submitted_by' value='{$submitted['submitted_user_name']}' placeholder='Name of the submitter' size='25' disabled='disabled' />
398 <input type='checkbox' id='edit-submitted-by' class='vertical-align-checkbox edit-checkbox-margin custom-checkbox' />
399 <label for='edit-submitted-by' class='custom-checkbox'><span></span>Edit</label>
400 </li>
401 <li class='submit-form-space'>
402 <label for='submitted-description' class='label-bold label-block'>Map description:</label>
403 <textarea placeholder='Short description of the map' id='submitted-description' name='submitted_description'>{$submitted['submitted_map_description']}</textarea>
404 </li>
405 <li class='submit-form-space'>
406 <input type='submit' name='update' id='submit-maps-update' value='Update submission' />
407 </li>
408 </ul>
409 </fieldset>
410 </form>";
411 }
412 }
413 }
414
415 // ACCEPT a submission
416 elseif( isset( $_GET['accept'] ) && !$bool_multiple_get )
417 {
418 // Convert the get id to submitted id
419 $submitted_id = trim( $_GET['accept'] );
420 // Make sure it's not an empty get and only has numeric value
421 if( is_numeric( $submitted_id ) )
422 {
423 $database->db_Query( "SELECT * FROM `2man_submit_maps` WHERE `submitted_id` = '{$submitted_id}'" );
424 $submitted = $database->db_Fetch( MYSQL_ASSOC );
425 // Make sure the id is from an legit submission, does the map exist?
426 if( isset( $submitted['submitted_map'] ) )
427 {
428 $submitted_map = $submitted['submitted_map'];
429 $submitted_map_author = $submitted['submitted_map_author'];
430 $submitted_map_size = $submitted['submitted_map_size'];
431 $submitted_map_desc = $submitted['submitted_map_description'];
432
433 // Change status to accepted
434 $database->db_Query( "UPDATE `2man_submit_maps` SET `submitted_status` = '{$map_status['accepted']}' WHERE `submitted_id` = '{$submitted_id}'" );
435 // Copy from submitted folder to 2man maps folder
436 rename( $maps_submitted."/".$submitted_map.".rar", $maps_folder."/".$submitted_map.".rar" );
437 // Implement the SQL for the accepted map
438 $database->db_Query( "INSERT INTO `2man_records` ( `map` ) VALUES ( '{$submitted_map}' )" );
439 // Add it to 2man downloads also right away, annoying to do manually later
440 $database->db_Query( "INSERT INTO `e107_download` VALUES ( '', '{$submitted_map}', 'download/2man_maps/".$submitted_map.".rar', '{$submitted_map_author}', '', '', '{$submitted_map_desc}', '{$submitted_map_size}', '0', '2', '1', '". time( ) ."', '', '', '1', '0', '', '0', '0' )" );
441 // Set the submissions status style for the jQuery at the bottom
442 $sub_handle->set_status( "The map <strong>{$submitted_map}</strong> has been accepted!", "admin", "green" );
443 }
444 }
445 }
446
447 // DENY a submission
448 elseif( isset( $_GET['deny'] ) && !$bool_multiple_get )
449 {
450 // Convert the get id to submitted id
451 $submitted_id = trim( $_GET['deny'] );
452 // Make sure it's not an empty get and only has numeric value
453 if( is_numeric( $submitted_id ) )
454 {
455 $database->db_Query( "SELECT `submitted_map` FROM `2man_submit_maps` WHERE `submitted_id` = '{$submitted_id}'" );
456 $submitted = $database->db_Fetch( MYSQL_ASSOC );
457 // Make sure the id is from an legit submission, does the map exist?
458 if( isset( $submitted['submitted_map'] ) )
459 {
460 $submitted_map = $submitted['submitted_map'];
461 // Change status to denied
462 $database->db_Query( "UPDATE `2man_submit_maps` SET `submitted_status` = '{$map_status['denied']}' WHERE `submitted_id` = '{$submitted_id}'" );
463 // Remove map
464 unlink( $maps_submitted."/".$submitted_map.".rar" );
465 // Set the submissions status style for the jQuery at the bottom
466 $sub_handle->set_status( "The map <strong>{$submitted_map}</strong> has been denied.", "admin", "red" );
467 }
468 }
469 }
470
471 $text .= "
472 <ul class='table-list table-list-titles'>
473 <li style='width: 25%'>Map name</li>
474 <li style='width: 15%'>Submitted by</li>
475 <li style='width: 10%' class='center-text'>Actions</li>
476 <li style='width: 25%' class='center-text'>Submitted</li>
477 <li style='width: 15%'>Status</li>
478 </ul>";
479
480 // Used to make different row colors,
481 $db_rows = 0;
482 // Display latest submission first
483 $database->db_Query( "SELECT * FROM `2man_submit_maps` ORDER BY `submitted_date` DESC" );
484 while( $data = $database->db_Fetch( MYSQL_ASSOC ) )
485 {
486 // Get and set it to an array - self explained
487 $submitted_status = get_map_status( $data['submitted_status'] );
488
489 $text .= "
490 <ul class='table-list". ( $db_rows % 2 == 0 ? " list-light" : "" ) ."'>
491 <li style='width: 25%'>";
492
493 // If map is denied, dont create a link, the map is deleted from submitted folder so just show map name
494 if( $data['submitted_status'] == $map_status['denied'] )
495 {
496 $text .= "
497 {$data['submitted_map']}";
498 }
499 // Map is accepted, link the download to the 2man maps folder, since it was removed from submitted when accepted to save space
500 elseif( $data['submitted_status'] == $map_status['accepted'] )
501 {
502 $text .= "
503 <a href='{$maps_folder}/{$data['submitted_map']}.rar' title='Download map'>{$data['submitted_map']}</a>";
504 }
505 // Pending, link to submitted folder where it lays
506 else
507 {
508 $text .= "
509 <a href='{$maps_submitted}/{$data['submitted_map']}.rar' title='Download map'>{$data['submitted_map']}</a>";
510 }
511
512 $text .= "
513 </li>
514 <li style='width: 15%'>". GiveCoolName( $data['submitted_user_id'] ) ."</li>
515 <li style='width: 10%' class='center-text'>
516 <a href='#' onclick='return Toggle( \"submitted_{$data['submitted_id']}\" );' title='Display information and functions'>Display</a>
517 </li>
518 <li style='width: 25%' class='center-text'>". date( "Y-m-d H:i", $data['submitted_date'] ) ."</li>
519 <li style='width: 15%'>". sprintf( "<span style='color: %s'><strong>%s</strong></span>", $submitted_status['color'], $submitted_status['status'] ) ."</li>
520 </ul>
521 <ul id='submitted_{$data['submitted_id']}' style='display: none' class='list-darker text-padding'>
522 <li><strong>Map author:</strong> ". htmlspecialchars( stripslashes( $data['submitted_map_author'] ) ) ."</li>
523 <li class='top-padding'><strong>Map Description:</strong> ". htmlspecialchars( stripslashes( $data['submitted_map_description'] ) ) ."</li>
524 <li id='submit-maps-list-actions' class='top-margin border-top-dashed'>
525 <ul>
526 <li>
527 <a href='?edit={$data['submitted_id']}' title='Edit this submission'>
528 <img src='/images/admin_images/edit_16.png' alt='edit' class='vertical-align-middle' /> Edit information
529 </a>
530 </li>";
531
532 // The submission has pending status, show available admin functions
533 if( $data['submitted_status'] == $map_status['pending'] )
534 {
535 $text .= "
536 <li>
537 <a href='#' onclick='return confirm_action( \"accept\", ". $data['submitted_id'] ." );' title='Accept this submission'>
538 <img src='/images/accept.png' alt='accept' class='vertical-align-middle' /> Accept map
539 </a>
540 </li>
541 <li>
542 <a href='#' onclick='return confirm_action( \"deny\", ". $data['submitted_id'] ." );' title='Deny this submission'>
543 <img src='/images/deny.png' alt='deny' class='vertical-align-middle' /> Deny map
544 </a>
545 </li>";
546 }
547
548 if( $data['submitted_update_date'] )
549 {
550 $text .= "
551 <li style='float: right'>
552 Submission updated: ". date( "Y-m-d H:i", $data['submitted_update_date'] ) ."
553 </li>";
554 }
555
556 $text .= "
557 </ul>
558 </li>
559 </ul>";
560
561 // Number of database rows += 1
562 $db_rows++;
563 }
564 }
565 // If not highly positioned admin, show the public (member) side of the submitted maps
566 else
567 {
568 $text .= "
569 <table border='0' cellpadding='0' cellspacing='0'>
570 <tr class='left-text'>
571 <th>Map name</th>
572 <th>Submitted by</th>
573 <th>Map author</th>
574 <th class='center-text'>Submitted</th>
575 <th>Status</th>
576 </tr>";
577
578 $db_rows = 0;
579 $database->db_Query( "SELECT * FROM `2man_submit_maps` ORDER BY `submitted_date` DESC" );
580 while( $data = $database->db_Fetch( MYSQL_ASSOC ) )
581 {
582 // Get and set it to an array - self explained
583 $submitted_status = get_map_status( $data['submitted_status'] );
584
585 $text .= "
586 <tr". ( $db_rows % 2 == 0 ? " class='list-light'" : "" ) .">
587 <td>{$data['submitted_map']}</td>
588 <td>". GiveCoolName( $data['submitted_user_id'] ) ."</td>
589 <td>". htmlspecialchars( stripslashes( $data['submitted_map_author'] ) ) ."</td>
590 <td class='center-text'>". date( "Y-m-d", $data['submitted_date'] ) ."</td>
591 <td>". sprintf( "<span style='color: %s'><strong>%s</strong></span>", $submitted_status['color'], $submitted_status['status'] ) ."</td>
592 </tr>";
593
594 $db_rows++;
595 }
596
597 $text .= "
598 </table>";
599 }
600
601 $text .= "
602 </div>";
603
604 // If status is set, show admins the new status and what happened
605 $get_admin_status = $sub_handle->get_status( "admin", "message" );
606 if( !empty( $get_admin_status ) )
607 {
608 // sprintf with an submission array provided by the admin functions will save alot of code rows
609 $js_admin_status = sprintf( "
610 <script type='text/javascript'>
611 jQuery.noConflict( );
612
613 jQuery( document ).ready( function( )
614 {
615 jQuery( '#submit-maps-form' ).prepend( '<p id=\"submit-maps-status-update\" class=\"dashed-border bottom-margin\" style=\"color: %s; display: none\">%s</p>' );
616 setTimeout( function( )
617 {
618 jQuery( '#submit-maps-status-update' ).fadeIn( 1000 );
619 setTimeout( function( )
620 {
621 jQuery( '#submit-maps-status-update' ).fadeOut( 1000 )
622 }, 3000 );
623 }, 1000 );
624 });
625 </script>", $sub_handle->get_status( "admin", "color" ), $sub_handle->get_status( "admin", "message" ) );
626 }
627 }
628
629 // Render the page, is the jQuery variable set print it out else add nothing
630 $ns->tablerender( e_PAGETITLE, $text. ( isset( $js_admin_status ) ? $js_admin_status : "" ) );
631 require_once( FOOTERF );
632?>