function flag_banner_controler() { $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 'main'; if (isset($_POST['importfolder']) && $_POST['importfolder']) { check_admin_referer('flag_addbanner'); $bannerfolder = $_POST['bannerfolder']; if (!empty($bannerfolder) and false === strpos($bannerfolder, '..')) { $crunch_list = flagAdmin::import_banner($bannerfolder); $mode = 'import'; } } $action = isset($_REQUEST['bulkaction']) ? $_REQUEST['bulkaction'] : false; if ($action == 'no_action') { $action = false; } switch ($mode) { case 'sort': check_admin_referer('flag_sort'); include_once dirname(__FILE__) . '/banner-sort.php'; flag_b_playlist_order(); break; case 'edit': $file = sanitize_flagname($_GET['playlist']); if (isset($_POST['updatePlaylist'])) { check_admin_referer('flag_update'); $title = esc_html($_POST['playlist_title']); $descr = esc_html($_POST['playlist_descr']); $data = array(); foreach ($_POST['item_a'] as $item_id => $item) { if ($action == 'delete_items' && in_array($item_id, $_POST['doaction'])) { continue; } $data[] = $item_id; } flagGallery::flagSaveWpMedia(); flagSave_bPlaylist($title, $descr, $data, $file); } if (isset($_POST['updatePlaylistSkin'])) { check_admin_referer('flag_update'); flagSave_bPlaylistSkin($file); } include_once dirname(__FILE__) . '/manage-banner.php'; flag_b_playlist_edit($file); break; case 'save': if (isset($_POST['items_array'])) { check_admin_referer('flag_update'); $title = esc_html($_POST['playlist_title']); $descr = esc_html($_POST['playlist_descr']); $data = $_POST['items_array']; $file = isset($_REQUEST['playlist']) ? sanitize_flagname($_REQUEST['playlist']) : false; flagGallery::flagSaveWpMedia(); flagSave_bPlaylist($title, $descr, $data, $file); } if (isset($_GET['playlist'])) { include_once dirname(__FILE__) . '/manage-banner.php'; flag_b_playlist_edit(); } else { flag_created_b_playlists(); flag_banner_wp_media_lib(); } break; case 'add': check_admin_referer('flag_add'); if (isset($_POST['items']) && isset($_GET['playlist'])) { $added = $_POST['items']; } elseif (isset($_GET['playlist'])) { $added = $_COOKIE['bannerboxplaylist_' . sanitize_flagname($_GET['playlist'])]; } else { $added = false; } flag_banner_wp_media_lib($added); break; case 'delete': check_admin_referer('flag_delete'); flag_b_playlist_delete(sanitize_flagname($_GET['playlist'])); case 'import': flag_crunch($crunch_list); case 'main': if (isset($_POST['updateMedia'])) { check_admin_referer('flag_update'); flagGallery::flagSaveWpMedia(); flagGallery::show_message(__('Media updated', 'flag')); } default: flag_created_b_playlists(); flag_banner_wp_media_lib(); break; } }