@unlink($save_path . $file_name);
            if (!move_uploaded_file($_FILES[$name]["tmp_name"], $save_path . $file_name)) {
                echo "File could not be saved. " . $uploadErrors[$_FILES[$name]['error']];
                exit(0);
            }
        }
    }
} elseif ($_GET['act'] == 'saveForPreview') {
    if (is_numeric($_POST['slideshow_id'])) {
        $slideshow_id = (int) $_POST['slideshow_id'];
        $uploadsDir = wp_upload_dir();
        $rows = $wpdb->get_results("SELECT `images_folder` FROM `" . $wpdb->prefix . "cu3er__slideshows` WHERE `id`='" . $slideshow_id . "'", ARRAY_A);
        foreach ($rows as $row) {
            $slideshow = $row;
        }
        $baseUrl = cu3er__resolveUrl(cu3er__removeDomainName($slideshow['images_folder'])) . cu3er__removeDomainName($slideshow['images_folder']);
        if (cu3er__isFallback($baseUrl . '/fallback')) {
            $rows = $wpdb->get_results("SELECT `image`, `position`, `id` FROM `" . $wpdb->prefix . "cu3er__slides` WHERE `slideshow_id`='" . $slideshow_id . "'", ARRAY_A);
            foreach ($rows as $row) {
                $oldSlide[$row['id']] = $row;
            }
            $rows = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "cu3er__defaults` WHERE `slideshow_id`='" . $slideshow_id . "'", ARRAY_A);
            foreach ($rows as $row) {
                $oldDefaults = $row;
            }
        }
        $_POST['default']['Defaults']['flipDirection'] = implode(",", $_POST['default']['Defaults']['flipDirection']);
        $defaults = $_POST['default']['Defaults'];
        $defaults['flipOrderFromCenter'] = $defaults['flipOrderFromCenter'] != 'false' ? 'true' : 'false';
        $defaults['flipShader'] = $defaults['flipShader'] != 'none' ? 'flat' : 'none';
        if (!cu3er__sql_magic($wpdb->prefix . 'cu3er__defaults', $defaults)) {
function display_cu3er($slideshow, $ret = false)
{
    if (is_numeric($slideshow)) {
        global $wpdb;
        // embeded code for showing cu3er //
        $row = $wpdb->get_row("SELECT * FROM `" . $wpdb->prefix . "cu3er__settings` LIMIT 1", ARRAY_A) or die(mysql_error());
        $settings = array();
        foreach ($row as $key => $value) {
            $row[$key] = stripslashes($value);
            $settings[$key] = str_replace("'", "\\'", $row[$key]);
        }
        $row = $wpdb->get_row("SELECT * FROM `" . $wpdb->prefix . "cu3er__slideshows` WHERE `id`='" . $slideshow . "'", ARRAY_A) or die(mysql_error());
        $slideshowS = array();
        foreach ($row as $key => $value) {
            $row[$key] = stripslashes($value);
            $slideshowS[$key] = str_replace("'", "\\'", $row[$key]);
        }
        $row = $wpdb->get_row("SELECT `use_post_images`,`posts_count` FROM `" . $wpdb->prefix . "cu3er__defaults` WHERE `slideshow_id`='" . $slideshow . "'", ARRAY_A) or die(mysql_error());
        $data = explode('|||||', cu3er__readFromFile($slideshow));
        $seo_str = $data[1];
        /*if($settings['licence'] != '') {
        			$data[0] = preg_replace('/\%3Clicence\%3E(.*?)\%2Flicence\%3E/', urlencode('<licence><![CDATA['. urldecode(trim($settings['licence'])) .']]></licence>'), $data[0]);
        		}*/
        $cObject = "var CU3ER_object = new CU3ER('CU3ER" . $slideshow . "');";
        $params = $slideshowS['backgroundType'] == 'transparent' ? "wmode : 'transparent'" : "bgcolor : '" . str_replace('0x', '#', $slideshowS['background']) . "'";
        $fjs = $slideshowS['force_js'] == 'yes' ? 'true' : 'false';
        $baseUrl = cu3er__resolveUrl(cu3er__removeDomainName($slideshowS['images_folder'], true)) . cu3er__removeDomainName($slideshowS['images_folder'], true);
        $fflash = cu3er__isFallback($baseUrl . '/fallback') ? 'false' : 'true';
        $fjs3d = $slideshowS['force_js3d'] == 'yes' ? ',display_js3d_first: true' : '';
        $responsive = $slideshowS['responsive'] == 'no' ? ',responsiveSlider: false' : '';
        $content = $seo_str != '' ? $seo_str : $slideshowS['content'];
        $images_var = '';
        if ($defaults['use_post_images'] == 'yes' && $defaults['posts_count'] > 0) {
            /*query_posts('showposts=' . $defaults['posts_count']);
            		while (have_posts()) : the_post();
            			$images[] = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
            		endwhile;*/
            $rPosts = new WP_Query();
            $rPosts->query('showposts=' . $defaults['posts_count']);
            while ($rPosts->have_posts()) {
                $rPosts->the_post();
                $images[] = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
            }
            wp_reset_query();
            $images_var = ',images:"' . implode(",", $images) . '"';
        }
        $slideshowS['width_type'] = $slideshowS['width_type'] == '%' ? '%' : '';
        $slideshowS['height_type'] = $slideshowS['height_type'] == '%' ? '%' : '';
        if ($slideshowS['width'] > 0) {
            $var = "<script type='text/javascript'>\n\t\t\t\t\t\tjQuery(document).ready(function(\$) {\n\t\t\t\t\t\t\t\$('#CU3ER" . $slideshow . "').cu3er({\n\t\t\t\t\t\t\t\tvars: {\n\t\t\t\t\t\t\t\t\txml_location: \"" . cu3er__removeDomainName($slideshowS['xml_location']) . "\",\n\t\t\t\t\t\t\t\t\txml_encoded: '" . $data[0] . "',\n\t\t\t\t\t\t\t\t\tswf_location: '" . $settings['cu3er_location'] . "?" . time() . "',\n\t\t\t\t\t\t\t\t\tcss_location: '" . WP_PLUGIN_URL . "/wpcu3er/css/CU3ER.css',\n\t\t\t\t\t\t\t\t\tjs_location: '" . $settings['js_player_location'] . "?" . time() . "',\n\t\t\t\t\t\t\t\t\twidth: '" . $slideshowS['width'] . $slideshowS['width_type'] . "',\n\t\t\t\t\t\t\t\t\theight: '" . $slideshowS['height'] . $slideshowS['height_type'] . "',\n\t\t\t\t\t\t\t\t\tforce_javascript: " . $fjs . ",\n\t\t\t\t\t\t\t\t\tforce_flash: " . $fflash . "" . $images_var . "" . $fjs3d . "" . $responsive . "\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tparams: {\n\t\t\t\t\t\t\t\t\t" . $params . ",\n\t\t\t\t\t\t\t\t\tallowScriptAccess: 'always'\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\tid:'CU3ER" . $slideshow . "',\n\t\t\t\t\t\t\t\t\tname:'CU3ER" . $slideshow . "'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t</script>" . $content;
        } else {
            $var = '';
        }
        if ($ret) {
            return $var;
        } else {
            echo '<div id="CU3ER' . $slideshow . '">' . $var . '</div>';
        }
    }
}