Exemple #1
0
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;
}
Exemple #2
0
function wfu_ajax_action_edit_shortcode()
{
    if (!current_user_can('manage_options')) {
        die;
    }
    if (!isset($_POST['upload_id']) || !isset($_POST['post_id']) || !isset($_POST['post_hash']) || !isset($_POST['shortcode_tag'])) {
        die;
    }
    //sanitize parameters
    $upload_id = sanitize_text_field($_POST['upload_id']);
    $post_id = wfu_sanitize_int($_POST['post_id']);
    $post_hash = wfu_sanitize_code($_POST['post_hash']);
    $shortcode_tag = wfu_sanitize_tag($_POST['shortcode_tag']);
    $data['post_id'] = $post_id;
    $data['post_hash'] = $post_hash;
    if (wfu_check_edit_shortcode($data)) {
        $post = get_post($data['post_id']);
        //get default value for uploadid
        $defs = wfu_attribute_definitions();
        $default = "";
        foreach ($defs as $key => $def) {
            if ($def['attribute'] == 'uploadid') {
                $default = $def['value'];
                break;
            }
        }
        //get page shortcodes
        $wfu_shortcodes = wfu_get_content_shortcodes($post, $shortcode_tag);
        //find the shortcodes' uploadid and the correct one
        $validkey = -1;
        foreach ($wfu_shortcodes as $key => $data) {
            $shortcode = trim(substr($data['shortcode'], strlen('[' . $shortcode_tag), -1));
            $shortcode_attrs = wfu_shortcode_string_to_array($shortcode);
            if (array_key_exists('uploadid', $shortcode_attrs)) {
                $uploadid = $shortcode_attrs['uploadid'];
            } else {
                $uploadid = $default;
            }
            if ($uploadid == $upload_id) {
                $validkey = $key;
                break;
            }
        }
        if ($validkey == -1) {
            die;
        }
        $data_enc = wfu_safe_store_shortcode_data(wfu_encode_array_to_string($wfu_shortcodes[$validkey]));
        $url = site_url() . '/wp-admin/options-general.php?page=wordpress_file_upload&tag=' . $shortcode_tag . '&action=edit_shortcode&data=' . $data_enc;
        die("wfu_edit_shortcode:success:" . wfu_plugin_encode_string($url));
    } else {
        die("wfu_edit_shortcode:check_page_obsolete:" . WFU_ERROR_PAGE_OBSOLETE);
    }
}
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'] : '');
    $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 == 'sync_db') {
        $affected_items = wfu_sync_database();
        $echo_str = wfu_manage_mainmenu('Database updated. ' . $affected_items . ' items where affected.');
    } elseif ($action == 'plugin_settings') {
        $echo_str = wfu_manage_settings();
    } elseif ($action == 'edit_shortcode' && $data_enc != "") {
        $data = wfu_decode_array_from_string($data_enc);
        if (wfu_check_edit_shortcode($data)) {
            wfu_shortcode_composer($data);
        } else {
            $echo_str = wfu_manage_mainmenu(WFU_DASHBOARD_EDIT_SHORTCODE_REJECTED);
        }
    } elseif ($action == 'delete_shortcode' && $data_enc != "") {
        $data = wfu_decode_array_from_string($data_enc);
        if (wfu_check_edit_shortcode($data)) {
            $echo_str = wfu_delete_shortcode_prompt($data);
        } else {
            $echo_str = wfu_manage_mainmenu(WFU_DASHBOARD_DELETE_SHORTCODE_REJECTED);
        }
    } elseif ($action == 'deleteshortcode' && $data_enc != "") {
        $data = wfu_decode_array_from_string($data_enc);
        if (wfu_check_edit_shortcode($data)) {
            wfu_delete_shortcode($data);
            $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;
}