/** * wpsc_recursive_copy function, copied from here and renamed: http://nz.php.net/copy * Why doesn't PHP have one of these built in? */ function wpsc_recursive_copy($src, $dst) { $dir = opendir($src); @mkdir($dst); while (false !== ($file = readdir($dir))) { if ($file != '.' && $file != '..') { if (is_dir($src . '/' . $file)) { wpsc_recursive_copy($src . '/' . $file, $dst . '/' . $file); } else { @copy($src . '/' . $file, $dst . '/' . $file); } } } closedir($dir); }
function wpsc_backup_theme() { $wp_theme_path = get_stylesheet_directory(); wpsc_recursive_copy($wp_theme_path, WPSC_THEME_BACKUP_DIR); $_SESSION['wpsc_themes_backup'] = true; $sendback = wp_get_referer(); wp_redirect($sendback); exit; }
function wpsc_copy_themes_to_uploads() { $old_theme_path = WPSC_CORE_THEME_PATH; $new_theme_path = WPSC_THEMES_PATH; $new_dir = @opendir($new_theme_path); $num = 0; $file_names = array(); while (($file = @readdir($new_dir)) !== false) { if (is_dir($new_theme_path . $file) && $file != ".." && $file != ".") { $file_names[] = $file; } } if (count($file_names) < 1) { $old_dir = @opendir($old_theme_path); while (($file = @readdir($old_dir)) !== false) { if (is_dir($old_theme_path . $file) && $file != ".." && $file != ".") { @wpsc_recursive_copy($old_theme_path . $file, $new_theme_path . $file); } } } }
function wpsc_test_copying_themes() { if (!current_user_can('manage_options')) { wp_die("You don't look like an administrator."); } $new_dir = @opendir(WPSC_THEMES_PATH); $num = 0; $file_names = array(); while (false !== ($file = @readdir($new_dir))) { if (is_dir(WPSC_THEMES_PATH . $file) && $file != ".." && $file != ".") { $file_names[] = $file; } } if (count($file_names) < 1) { $old_dir = @opendir(WPSC_CORE_THEME_PATH); while (($file = @readdir($old_dir)) !== false) { if (is_dir(WPSC_CORE_THEME_PATH . $file) && $file != ".." && $file != ".") { $success = wpsc_recursive_copy(WPSC_CORE_THEME_PATH . $file, WPSC_THEMES_PATH . $file); echo "old_file:" . WPSC_CORE_THEME_PATH . $file . "<br />"; echo "new_file:" . WPSC_THEMES_PATH . $file . "<br />"; echo "<pre>" . print_r($success, true) . "</pre>"; } } } }
function wpsc_test_copying_themes() { $old_theme_path = WPSC_FILE_PATH . "/themes/"; $new_theme_path = WPSC_THEMES_PATH; $new_dir = @opendir($new_theme_path); $num = 0; $file_names = array(); while (($file = @readdir($new_dir)) !== false) { if (is_dir($new_theme_path . $file) && $file != ".." && $file != ".") { $file_names[] = $file; } } if (count($file_names) < 1) { $old_dir = @opendir($old_theme_path); while (($file = @readdir($old_dir)) !== false) { if (is_dir($old_theme_path . $file) && $file != ".." && $file != ".") { $success = wpsc_recursive_copy($old_theme_path . $file, $new_theme_path . $file); echo "old_file:" . $old_theme_path . $file . "<br />"; echo "new_file:" . $new_theme_path . $file . "<br />"; echo "<pre>" . print_r($success, true) . "</pre>"; } } } }