コード例 #1
0
 /**
  * Do Export file
  */
 function do_export_file()
 {
     if (is_user_logged_in() && isset($_GET['themify_builder_export_file']) && $_GET['themify_builder_export_file'] == true && check_admin_referer('themify_builder_export_nonce')) {
         $postid = (int) $_GET['postid'];
         $postdata = get_post($postid);
         $data_name = $postdata->post_name;
         $builder_data = get_post_meta($postid, apply_filters('themify_builder_meta_key', '_themify_builder_settings'), true);
         $builder_data = maybe_serialize($builder_data);
         if (class_exists('ZipArchive')) {
             $datafile = 'builder_data_export.txt';
             $handler = @fopen($datafile, 'w');
             @fwrite($handler, $builder_data);
             @fclose($handler);
             $files_to_zip = array($datafile);
             $file = $data_name . '_themify_builder_export_' . date('Y_m_d') . '.zip';
             $result = themify_create_zip($files_to_zip, $file, true);
         }
         if (isset($result) && $result) {
             if (isset($file) && file_exists($file)) {
                 ob_start();
                 header('Pragma: public');
                 header('Expires: 0');
                 header("Content-type: application/force-download");
                 header('Content-Disposition: attachment; filename="' . $file . '"');
                 header("Content-Transfer-Encoding: Binary");
                 header("Content-length: " . filesize($file));
                 header('Connection: close');
                 ob_clean();
                 flush();
                 readfile($file);
                 unlink($datafile);
                 unlink($file);
                 exit;
             } else {
                 return false;
             }
         } else {
             if (ini_get('zlib.output_compression')) {
                 ini_set('zlib.output_compression', 'Off');
             }
             ob_start();
             header('Content-Type: application/force-download');
             header('Pragma: public');
             header('Expires: 0');
             header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
             header('Cache-Control: private', false);
             header('Content-Disposition: attachment; filename="' . $data_name . '_themify_builder_export_' . date("Y_m_d") . '.txt"');
             header('Content-Transfer-Encoding: binary');
             ob_clean();
             flush();
             echo $builder_data;
             exit;
         }
     }
 }
コード例 #2
0
/**
 * Export Settings to zip file and prompt to download
 * NOTE: This function is not called through AJAX but it is kept here for consistency. 
 * @since 1.1.3
 * @package themify
 */
function themify_export()
{
    if (isset($_GET['export']) && 'themify' == $_GET['export']) {
        check_admin_referer('themify_export_nonce');
        $theme = wp_get_theme();
        $theme_name = $theme->display('Name');
        if (class_exists('ZipArchive')) {
            $theme_name_lc = strtolower($theme_name);
            $datafile = 'data_export.txt';
            $handler = @fopen($datafile, 'w');
            @fwrite($handler, serialize(themify_get_data()));
            @fclose($handler);
            $files_to_zip = array('../wp-content/themes/' . $theme_name_lc . '/custom-modules.php', '../wp-content/themes/' . $theme_name_lc . '/custom-functions.php', '../wp-content/themes/' . $theme_name_lc . '/custom-config.php', '../wp-content/themes/' . $theme_name_lc . '/custom_style.css', $datafile);
            //print_r($files_to_zip);
            $file = $theme_name . '_themify_export_' . date('Y_m_d') . '.zip';
            $result = themify_create_zip($files_to_zip, $file, true);
        }
        if (isset($result) && $result) {
            if (isset($file) && file_exists($file)) {
                ob_start();
                header('Pragma: public');
                header('Expires: 0');
                header("Content-type: application/force-download");
                header('Content-Disposition: attachment; filename="' . $file . '"');
                header("Content-Transfer-Encoding: Binary");
                header("Content-length: " . filesize($file));
                header('Connection: close');
                ob_clean();
                flush();
                readfile($file);
                unlink($datafile);
                unlink($file);
                exit;
            } else {
                return false;
            }
        } else {
            if (ini_get('zlib.output_compression')) {
                ini_set('zlib.output_compression', 'Off');
            }
            ob_start();
            header('Content-Type: application/force-download');
            header('Pragma: public');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Cache-Control: private', false);
            header('Content-Disposition: attachment; filename="' . $theme_name . '_themify_export_' . date("Y_m_d") . '.txt"');
            header('Content-Transfer-Encoding: binary');
            ob_clean();
            flush();
            echo serialize(themify_get_data());
            exit;
        }
    }
    return false;
}
コード例 #3
0
/**
 * Export Settings to zip file and prompt to download
 * NOTE: This function is not called through AJAX but it is kept here for consistency. 
 * @since 1.1.3
 * @package themify
 */
function themify_export()
{
    if (isset($_GET['export']) && 'themify' == $_GET['export']) {
        check_admin_referer('themify_export_nonce');
        $theme = wp_get_theme();
        $theme_name = $theme->display('Name');
        if (!function_exists('WP_Filesystem')) {
            require_once ABSPATH . 'wp-admin/includes/file.php';
        }
        WP_Filesystem();
        global $wp_filesystem;
        if (class_exists('ZipArchive')) {
            $theme_name_lc = strtolower($theme_name);
            $datafile = 'data_export.txt';
            $wp_filesystem->put_contents($datafile, serialize(themify_get_data()));
            $files_to_zip = array('../wp-content/themes/' . $theme_name_lc . '/custom-modules.php', '../wp-content/themes/' . $theme_name_lc . '/custom-functions.php', '../wp-content/themes/' . $theme_name_lc . '/custom-config.php', '../wp-content/themes/' . $theme_name_lc . '/custom_style.css', $datafile);
            //print_r($files_to_zip);
            $file = $theme_name . '_themify_export_' . date('Y_m_d') . '.zip';
            $result = themify_create_zip($files_to_zip, $file, true);
        }
        if (isset($result) && $result) {
            if (isset($file) && $wp_filesystem->exists($file)) {
                ob_start();
                header('Pragma: public');
                header('Expires: 0');
                header("Content-type: application/force-download");
                header('Content-Disposition: attachment; filename="' . $file . '"');
                header("Content-Transfer-Encoding: Binary");
                header("Content-length: " . filesize($file));
                header('Connection: close');
                ob_clean();
                flush();
                echo $wp_filesystem->get_contents($file);
                $wp_filesystem->delete($datafile);
                $wp_filesystem->delete($file);
                exit;
            } else {
                return false;
            }
        } else {
            if (ini_get('zlib.output_compression')) {
                /**
                 * Turn off output buffer compression for proper zip download.
                 * @since 2.0.2
                 */
                $srv_stg = 'ini' . '_' . 'set';
                call_user_func($srv_stg, 'zlib.output_compression', 'Off');
            }
            ob_start();
            header('Content-Type: application/force-download');
            header('Pragma: public');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Cache-Control: private', false);
            header('Content-Disposition: attachment; filename="' . $theme_name . '_themify_export_' . date("Y_m_d") . '.txt"');
            header('Content-Transfer-Encoding: binary');
            ob_clean();
            flush();
            echo serialize(themify_get_data());
            exit;
        }
    }
    return false;
}
コード例 #4
0
 /**
  * Do Export file
  */
 function do_export_file()
 {
     if (is_user_logged_in() && isset($_GET['themify_builder_export_file']) && $_GET['themify_builder_export_file'] == true && check_admin_referer('themify_builder_export_nonce')) {
         $postid = (int) $_GET['postid'];
         $postdata = get_post($postid);
         $data_name = $postdata->post_name;
         global $ThemifyBuilder;
         $builder_data = $ThemifyBuilder->get_builder_data($postid);
         $builder_data = json_encode($builder_data);
         if (!function_exists('WP_Filesystem')) {
             require_once ABSPATH . 'wp-admin/includes/file.php';
         }
         WP_Filesystem();
         global $wp_filesystem;
         if (class_exists('ZipArchive')) {
             $datafile = 'builder_data_export.txt';
             $wp_filesystem->put_contents($datafile, $builder_data, FS_CHMOD_FILE);
             $files_to_zip = array($datafile);
             $file = $data_name . '_themify_builder_export_' . date('Y_m_d') . '.zip';
             $result = themify_create_zip($files_to_zip, $file, true);
         }
         if (isset($result) && $result) {
             if (isset($file) && file_exists($file)) {
                 ob_start();
                 header('Pragma: public');
                 header('Expires: 0');
                 header("Content-type: application/force-download");
                 header('Content-Disposition: attachment; filename="' . $file . '"');
                 header("Content-Transfer-Encoding: Binary");
                 header("Content-length: " . filesize($file));
                 header('Connection: close');
                 ob_clean();
                 flush();
                 echo $wp_filesystem->get_contents($file);
                 unlink($datafile);
                 unlink($file);
                 exit;
             } else {
                 return false;
             }
         } else {
             if (ini_get('zlib.output_compression')) {
                 /**
                  * Turn off output buffer compression for proper zip download.
                  * @since 2.0.2
                  */
                 $srv_stg = 'ini' . '_' . 'set';
                 call_user_func($srv_stg, 'zlib.output_compression', 'Off');
             }
             ob_start();
             header('Content-Type: application/force-download');
             header('Pragma: public');
             header('Expires: 0');
             header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
             header('Cache-Control: private', false);
             header('Content-Disposition: attachment; filename="' . $data_name . '_themify_builder_export_' . date("Y_m_d") . '.txt"');
             header('Content-Transfer-Encoding: binary');
             ob_clean();
             flush();
             echo $builder_data;
             exit;
         }
     }
 }
コード例 #5
0
/**
 * Export Settings to zip file and prompt to download
 * NOTE: This function is not called through AJAX but it is kept here for consistency. 
 * @since 1.1.3
 * @package themify
 */
function themify_export()
{
    //Check nonce of export feature
    check_admin_referer('themify_export_nonce');
    global $theme;
    if (class_exists('ZipArchive')) {
        $datafile = 'data_export.txt';
        $handler = fopen($datafile, 'w');
        fwrite($handler, serialize(get_data()));
        fclose($handler);
        $files_to_zip = array('../wp-content/themes/' . $theme['Name'] . '/custom-modules.php', '../wp-content/themes/' . $theme['Name'] . '/custom-functions.php', '../wp-content/themes/' . $theme['Name'] . '/custom-config.xml', $datafile);
        print_r($files_to_zip);
        $file = $theme['Name'] . '_themify_export_' . date("Y-m-d") . '.zip';
        $result = themify_create_zip($files_to_zip, $file, true);
        if ($result) {
            if (isset($file) && file_exists($file)) {
                header("Pragma: public");
                header("Expires: 0");
                header("Content-type: application/zip");
                header('Content-Disposition: inline; filename="' . $file . '"');
                header("Content-Transfer-Encoding: Binary");
                header("Content-length: " . filesize($file));
                header('Content-Type: application/octet-stream');
                header('Content-Disposition: attachment; filename="' . $file . '"');
                ob_clean();
                flush();
                readfile($file);
            } else {
                return false;
            }
            unlink($datafile);
            unlink($file);
        }
    } else {
        if (ini_get('zlib.output_compression')) {
            ini_set('zlib.output_compression', 'Off');
        }
        header('Pragma: public');
        header('Expires: 0');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Cache-Control: private', false);
        header('Content-Type: application/force-download');
        header('Content-Disposition: attachment; filename="' . $theme['Name'] . '_themify_export_' . date("Y-m-d") . '.txt"');
        header('Content-Transfer-Encoding: binary');
        ob_clean();
        flush();
        echo serialize(get_data());
    }
    return;
}
コード例 #6
0
function themify_export()
{
    global $theme;
    $datafile = "data_export.txt";
    $handler = fopen($datafile, 'w');
    if (class_exists('ZipArchive') && $handler != false) {
        fwrite($handler, serialize(get_data()));
        fclose($handler);
        $files_to_zip = array('../config.xml', '../custom_modules.php', '../custom_widgets.php', $datafile);
        $file = $theme['Name'] . '_themify_export_' . date("Y-m-d") . '.zip';
        $result = themify_create_zip($files_to_zip, $file, true);
        if ($result) {
            themify_force_download($file);
            unlink($datafile);
            unlink($file);
        }
    } else {
        if (ini_get('zlib.output_compression')) {
            ini_set('zlib.output_compression', 'Off');
        }
        header('Pragma: public');
        header('Expires: 0');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Cache-Control: private', false);
        header('Content-Type: application/force-download');
        header('Content-Disposition: attachment; filename="' . $theme['Name'] . '_themify_export_' . date("Y-m-d") . '.txt"');
        header('Content-Transfer-Encoding: binary');
        echo serialize(get_data());
        exit;
    }
}