function wordpress_file_upload_manage_dashboard() { $_POST = stripslashes_deep($_POST); $_GET = stripslashes_deep($_GET); $action = !empty($_POST['action']) ? $_POST['action'] : (!empty($_GET['action']) ? $_GET['action'] : ''); $dir = !empty($_POST['dir']) ? $_POST['dir'] : (!empty($_GET['dir']) ? $_GET['dir'] : ''); $file = !empty($_POST['file']) ? $_POST['file'] : (!empty($_GET['file']) ? $_GET['file'] : ''); $data_enc = !empty($_POST['data']) ? $_POST['data'] : (!empty($_GET['data']) ? $_GET['data'] : ''); $postid = !empty($_POST['postid']) ? $_POST['postid'] : (!empty($_GET['postid']) ? $_GET['postid'] : ''); $nonce = !empty($_POST['nonce']) ? $_POST['nonce'] : (!empty($_GET['nonce']) ? $_GET['nonce'] : ''); $tag = !empty($_POST['tag']) ? $_POST['tag'] : (!empty($_GET['tag']) ? $_GET['tag'] : ''); $echo_str = ""; if ($action == 'edit_settings') { wfu_update_settings(); $echo_str = wfu_manage_settings(); } elseif ($action == 'shortcode_composer') { $echo_str = wfu_shortcode_composer(); } elseif ($action == 'file_browser') { $echo_str = wfu_browse_files($dir); } elseif ($action == 'view_log') { $echo_str = wfu_view_log(); } elseif ($action == 'rename_file' && $file != "") { $echo_str = wfu_rename_file_prompt($file, 'file', false); } elseif ($action == 'rename_dir' && $file != "") { $echo_str = wfu_rename_file_prompt($file, 'dir', false); } elseif ($action == 'renamefile' && $file != "") { if (wfu_rename_file($file, 'file')) { $echo_str = wfu_browse_files($dir); } else { $echo_str = wfu_rename_file_prompt($file, 'file', true); } } elseif ($action == 'renamedir' && $file != "") { if (wfu_rename_file($file, 'dir')) { $echo_str = wfu_browse_files($dir); } else { $echo_str = wfu_rename_file_prompt($file, 'dir', true); } } elseif ($action == 'delete_file' && $file != "") { $echo_str = wfu_delete_file_prompt($file, 'file'); } elseif ($action == 'delete_dir' && $file != "") { $echo_str = wfu_delete_file_prompt($file, 'dir'); } elseif ($action == 'deletefile' && $file != "") { wfu_delete_file($file, 'file'); $echo_str = wfu_browse_files($dir); } elseif ($action == 'deletedir' && $file != "") { wfu_delete_file($file, 'dir'); $echo_str = wfu_browse_files($dir); } elseif ($action == 'create_dir') { $echo_str = wfu_create_dir_prompt($dir, false); } elseif ($action == 'createdir') { if (wfu_create_dir($dir)) { $echo_str = wfu_browse_files($dir); } else { $echo_str = wfu_create_dir_prompt($dir, true); } } elseif ($action == 'file_details' && $file != "") { $echo_str = wfu_file_details($file, false); } elseif ($action == 'edit_filedetails' && $file != "") { wfu_edit_filedetails($file); $echo_str = wfu_file_details($file, false); } elseif ($action == 'maintenance_actions') { $echo_str = wfu_maintenance_actions(); } elseif ($action == 'sync_db') { $affected_items = wfu_sync_database(); $echo_str = wfu_maintenance_actions('Database updated. ' . $affected_items . ' items where affected.'); } elseif ($action == 'clean_log_ask') { $echo_str = wfu_clean_log_prompt(); } elseif ($action == 'clean_log') { $ret = wfu_clean_log(); if ($ret <= -1) { $echo_str = wfu_maintenance_actions(); } else { $echo_str = wfu_maintenance_actions('Database cleaned. ' . $ret . ' items where affected.'); } } elseif ($action == 'plugin_settings') { $echo_str = wfu_manage_settings(); } elseif ($action == 'add_shortcode' && $postid != "" && $nonce != "" && $tag != "") { if ($_SESSION['wfu_add_shortcode_ticket_for_' . $tag] != $nonce) { $echo_str = wfu_manage_mainmenu(); } elseif (wfu_add_shortcode($postid, $tag)) { $echo_str = wfu_manage_mainmenu(); } else { $echo_str = wfu_manage_mainmenu(WFU_DASHBOARD_ADD_SHORTCODE_REJECTED); } $_SESSION['wfu_add_shortcode_ticket'] = 'noticket'; } elseif ($action == 'edit_shortcode' && $data_enc != "" && $tag != "") { $data = wfu_decode_array_from_string(wfu_get_shortcode_data_from_safe($data_enc)); if ($data['post_id'] == "" || wfu_check_edit_shortcode($data)) { wfu_shortcode_composer($data, $tag); } else { $echo_str = wfu_manage_mainmenu(WFU_DASHBOARD_EDIT_SHORTCODE_REJECTED); } } elseif ($action == 'delete_shortcode' && $data_enc != "") { $data = wfu_decode_array_from_string(wfu_get_shortcode_data_from_safe($data_enc)); if (wfu_check_edit_shortcode($data)) { $echo_str = wfu_delete_shortcode_prompt($data_enc); } else { $echo_str = wfu_manage_mainmenu(WFU_DASHBOARD_DELETE_SHORTCODE_REJECTED); } } elseif ($action == 'deleteshortcode' && $data_enc != "") { $data = wfu_decode_array_from_string(wfu_get_shortcode_data_from_safe($data_enc)); if (wfu_check_edit_shortcode($data)) { if (wfu_delete_shortcode($data)) { wfu_clear_shortcode_data_from_safe($data_enc); } $echo_str = wfu_manage_mainmenu(); } else { $echo_str = wfu_manage_mainmenu(WFU_DASHBOARD_DELETE_SHORTCODE_REJECTED); } } else { $echo_str = wfu_manage_mainmenu(); } echo $echo_str; }
function wfu_manage_settings($message = '') { if (!current_user_can('manage_options')) { return wfu_shortcode_composer(); } $siteurl = site_url(); $plugin_options = wfu_decode_plugin_options(get_option("wordpress_file_upload_options")); $echo_str = '<div class="wrap">'; $echo_str .= "\n\t" . '<h2>Wordpress File Upload Control Panel</h2>'; $echo_str .= "\n\t" . '<div style="margin-top:20px;">'; $echo_str .= "\n\t\t" . '<a href="' . $siteurl . '/wp-admin/options-general.php?page=wordpress_file_upload&action=manage_mainmenu" class="button" title="go back">Go to Main Menu</a>'; $echo_str .= "\n\t\t" . '<h2 style="margin-bottom: 10px; margin-top: 20px;">Settings</h2>'; $echo_str .= "\n\t\t" . '<form enctype="multipart/form-data" name="editsettings" id="editsettings" method="post" action="' . $siteurl . '/wp-admin/options-general.php?page=wordpress_file_upload&action=edit_settings" class="validate">'; $nonce = wp_nonce_field('wfu_edit_admin_settings', '_wpnonce', false, false); $nonce_ref = wp_referer_field(false); $echo_str .= "\n\t\t\t" . $nonce; $echo_str .= "\n\t\t\t" . $nonce_ref; $echo_str .= "\n\t\t\t" . '<input type="hidden" name="action" value="edit_settings">'; $echo_str .= "\n\t\t\t" . '<table class="form-table">'; $echo_str .= "\n\t\t\t\t" . '<tbody>'; $echo_str .= "\n\t\t\t\t\t" . '<tr class="form-field">'; $echo_str .= "\n\t\t\t\t\t\t" . '<th scope="row">'; $echo_str .= "\n\t\t\t\t\t\t\t" . '<label for="wfu_hashfiles">Hash Files</label>'; $echo_str .= "\n\t\t\t\t\t\t" . '</th>'; $echo_str .= "\n\t\t\t\t\t\t" . '<td>'; $echo_str .= "\n\t\t\t\t\t\t\t" . '<input name="wfu_hashfiles" id="wfu_hashfiles" type="checkbox"' . ($plugin_options['hashfiles'] == '1' ? ' checked="checked"' : '') . ' style="width:auto;" /> Enables better control of uploaded files, but slows down performance when uploaded files are larger than 100MBytes'; $echo_str .= "\n\t\t\t\t\t\t\t" . '<p style="cursor: text; font-size:9px; padding: 0px; margin: 0px; width: 95%; color: #AAAAAA;">Current value: <strong>' . ($plugin_options['hashfiles'] == '1' ? 'Yes' : 'No') . '</strong></p>'; $echo_str .= "\n\t\t\t\t\t\t" . '</td>'; $echo_str .= "\n\t\t\t\t\t" . '</tr>'; $echo_str .= "\n\t\t\t\t\t" . '<tr class="form-field">'; $echo_str .= "\n\t\t\t\t\t\t" . '<th scope="row">'; $echo_str .= "\n\t\t\t\t\t\t\t" . '<label for="wfu_basedir">Base Directory</label>'; $echo_str .= "\n\t\t\t\t\t\t" . '</th>'; $echo_str .= "\n\t\t\t\t\t\t" . '<td>'; $echo_str .= "\n\t\t\t\t\t\t\t" . '<input name="wfu_basedir" id="wfu_basedir" type="text" value="' . $plugin_options['basedir'] . '" />'; $echo_str .= "\n\t\t\t\t\t\t\t" . '<p style="cursor: text; font-size:9px; padding: 0px; margin: 0px; width: 95%; color: #AAAAAA;">Current value: <strong>' . $plugin_options['basedir'] . '</strong></p>'; $echo_str .= "\n\t\t\t\t\t\t" . '</td>'; $echo_str .= "\n\t\t\t\t\t" . '</tr>'; $echo_str .= "\n\t\t\t\t" . '</tbody>'; $echo_str .= "\n\t\t\t" . '</table>'; $echo_str .= "\n\t\t\t" . '<p class="submit">'; $echo_str .= "\n\t\t\t\t" . '<input type="submit" class="button-primary" name="submit" value="Update" />'; $echo_str .= "\n\t\t\t" . '</p>'; $echo_str .= "\n\t\t" . '</form>'; $echo_str .= "\n\t" . '</div>'; $echo_str .= "\n" . '</div>'; echo $echo_str; }