diff -r 32102edaa81b -r c7c0fbc09788 web/wp-content/plugins/duplicator/duplicator.php
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/wp-content/plugins/duplicator/duplicator.php Mon Dec 03 16:30:36 2012 -0800
@@ -0,0 +1,304 @@
+prefix . "duplicator";
+
+ //PRIMARY KEY must have 2 spaces before for dbDelta
+ $sql = "CREATE TABLE `{$table_name}` (
+ id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ token VARCHAR(25) NOT NULL,
+ packname VARCHAR(250) NOT NULL,
+ zipname VARCHAR(250) NOT NULL,
+ zipsize INT (11),
+ created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+ owner VARCHAR(60) NOT NULL,
+ settings LONGTEXT NOT NULL)" ;
+
+ require_once(DUPLICATOR_WPROOTPATH . 'wp-admin/includes/upgrade.php');
+ @dbDelta($sql);
+
+ $duplicator_opts = array(
+ 'dbhost' =>'localhost',
+ 'dbname' =>'',
+ 'dbuser' =>'',
+ 'nurl' =>'',
+ 'email-me' =>"{$GLOBALS['duplicator_opts']['email-me']}",
+ 'email_others' =>"{$GLOBALS['duplicator_opts']['email_others']}",
+ 'max_time' =>$GLOBALS['duplicator_opts']['max_time'],
+ 'max_memory' =>$GLOBALS['duplicator_opts']['max_memory'],
+ 'dir_bypass' =>"{$GLOBALS['duplicator_opts']['dir_bypass']}",
+ 'log_level' =>'0',
+ 'dbiconv' =>"{$GLOBALS['duplicator_opts']['dbiconv']}",
+ 'skip_ext' =>"{$GLOBALS['duplicator_opts']['skip_ext']}",
+ 'rm_snapshot' =>"{$GLOBALS['duplicator_opts']['rm_snapshot']}");
+
+ update_option('duplicator_version_plugin', DUPLICATOR_VERSION);
+ update_option('duplicator_options', serialize($duplicator_opts));
+
+ //CLEANUP LEGACY
+ //PRE 0.2.9
+ delete_option('duplicator_version_database');
+ $wpdb->query("ALTER TABLE `{$table_name}` CHANGE bid id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT");
+ $wpdb->query("ALTER TABLE `{$table_name}` DROP COLUMN ver_db");
+ $wpdb->query("ALTER TABLE `{$table_name}` DROP COLUMN ver_plug");
+ $wpdb->query("ALTER TABLE `{$table_name}` DROP COLUMN status");
+ $wpdb->query("ALTER TABLE `{$table_name}` DROP COLUMN type");
+
+ //Setup All Directories
+ duplicator_init_snapshotpath();
+ }
+
+ /* UPDATE
+ register_activation_hook is not called when a plugin is updated
+ so we need to use the following function */
+ function duplicator_update() {
+ if (DUPLICATOR_VERSION != get_option("duplicator_version_plugin")) {
+ duplicator_activate();
+ }
+ }
+
+
+ /* DEACTIVATION
+ Only called when plugin is deactivated */
+ function duplicator_deactivate() {
+ //No actions needed yet
+ }
+
+
+ /* UNINSTALL
+ Uninstall all duplicator logic */
+ function duplicator_uninstall() {
+ global $wpdb;
+ $table_name = $wpdb->prefix . "duplicator";
+ $wpdb->query("DROP TABLE `{$table_name}`");
+
+ delete_option('duplicator_version_plugin');
+ delete_option('duplicator_options');
+
+ if ($GLOBALS['duplicator_opts']['rm_snapshot']) {
+
+ $ssdir = duplicator_safe_path(DUPLICATOR_SSDIR_PATH);
+
+ //Sanity check for strange setup
+ $check = glob("{$ssdir}/wp-config.php");
+ if (count($check) == 0) {
+
+ //PHP is sometimes flaky so lets do a sanity check
+ foreach (glob("{$ssdir}/*_database.sql") as $file) { if (strstr($file, '_database.sql')) {@unlink("{$file}");} }
+ foreach (glob("{$ssdir}/*_installer.php") as $file) { if (strstr($file, '_installer.php')) {@unlink("{$file}");} }
+ foreach (glob("{$ssdir}/*_package.zip") as $file) { if (strstr($file, '_package.zip')) {@unlink("{$file}");} }
+ foreach (glob("{$ssdir}/*.log") as $file) { if (strstr($file, '.log')) {@unlink("{$file}");} }
+
+ //Check for core files and only continue removing data if the snapshots directory
+ //has not been edited by 3rd party sources, this helps to keep the system stable
+ $files = glob("{$ssdir}/*");
+ if(is_array($files) && count($files) == 3)
+ {
+ $defaults = array("{$ssdir}/index.php", "{$ssdir}/robots.txt", "{$ssdir}/dtoken.php");
+ $compare = array_diff($defaults, $files);
+
+ if (count($compare) == 0) {
+ foreach($defaults as $file) {@unlink("{$file}");}
+ @unlink("{$ssdir}/.htaccess");
+ @rmdir($ssdir);
+ }
+ //No packages have ever been created
+ } else if(is_array($files) && count($files) == 1) {
+ $defaults = array("{$ssdir}/index.php");
+ $compare = array_diff($defaults, $files);
+ if (count($compare) == 0) {
+ @unlink("{$ssdir}/index.php");
+ @rmdir($ssdir);
+ }
+ }
+
+ }
+ }
+ }
+
+
+ /* META LINK ADDONS
+ Adds links to the plugins manager page */
+ function duplicator_meta_links( $links, $file ) {
+ $plugin = plugin_basename(__FILE__);
+ // create link
+ if ( $file == $plugin ) {
+ $links[] = '' . __( 'FAQ', 'wpduplicator' ) . '';
+ $links[] = '' . __( 'Partner', 'wpduplicator' ) . '';
+ $links[] = '' . __( 'Approved Hosts', 'wpduplicator' ) . '';
+ return $links;
+ }
+ return $links;
+ }
+
+ //HOOKS & ACTIONS
+ load_plugin_textdomain('wpduplicator' , FALSE, basename( dirname( __FILE__ ) ) . '/lang/' );
+ register_activation_hook(__FILE__ , 'duplicator_activate');
+ register_deactivation_hook(__FILE__ , 'duplicator_deactivate');
+ register_uninstall_hook(__FILE__ , 'duplicator_uninstall');
+
+ add_action('plugins_loaded', 'duplicator_update');
+ add_action('admin_init', 'duplicator_init' );
+ add_action('admin_menu', 'duplicator_menu');
+ add_action('wp_ajax_duplicator_system_check', 'duplicator_system_check');
+ add_action('wp_ajax_duplicator_system_directory', 'duplicator_system_directory');
+ add_action('wp_ajax_duplicator_delete', 'duplicator_delete');
+ add_action('wp_ajax_duplicator_create', 'duplicator_create');
+ add_action('wp_ajax_duplicator_settings', 'duplicator_settings');
+ add_filter('plugin_action_links', 'duplicator_manage_link', 10, 2 );
+ add_filter('plugin_row_meta', 'duplicator_meta_links', 10, 2 );
+
+
+ /**
+ * DUPLICATOR_INIT
+ * Init routines */
+ function duplicator_init() {
+ /* Register our stylesheet. */
+ wp_register_style('jquery-ui', DUPLICATOR_PLUGIN_URL . 'css/jquery-ui.css', null , "1.8.21" );
+ wp_register_style('duplicator_style', DUPLICATOR_PLUGIN_URL . 'css/style.css' );
+ }
+
+ /**
+ * DUPLICATOR_VIEWS
+ * Inlcude all visual elements */
+ function duplicator_main_page() {include 'inc/page.main.php';}
+ //Diagnostics Page
+ function duplicator_diag_page() {include 'inc/page.diag.php';}
+ //Support Page
+ function duplicator_support_page() {include 'inc/page.support.php';}
+ //All About Page
+ function duplicator_about_page() {include 'inc/page.about.php';}
+
+ /**
+ * DUPLICATOR_MENU
+ * Loads the menu item into the WP tools section and queues the actions for only this plugin */
+ function duplicator_menu() {
+ //Main Menu
+ $page_main = add_menu_page('Duplicator', 'Duplicator', "import", basename(__FILE__), 'duplicator_main_page', plugins_url('duplicator/img/create.png'));
+ add_submenu_page(basename(__FILE__), __('Dashboard', 'wpduplicator'), __('Dashboard', 'wpduplicator'), "import" , basename(__FILE__), 'duplicator_main_page');
+ //Sub Menus
+ $page_diag = add_submenu_page(basename(__FILE__), __('Diagnostics', 'wpduplicator'), __('Diagnostics', 'wpduplicator'), 'import', 'duplicator_diag_page', 'duplicator_diag_page');
+ $page_support = add_submenu_page(basename(__FILE__), __('Support', 'wpduplicator'), __('Support', 'wpduplicator'), 'import', 'duplicator_support_page', 'duplicator_support_page');
+ $page_about = add_submenu_page(basename(__FILE__), __('All About', 'wpduplicator'), __('All About', 'wpduplicator'), 'import', 'duplicator_about_page', 'duplicator_about_page');
+
+
+ //Apply scripts and styles
+ add_action('admin_print_scripts-' . $page_main, 'duplicator_scripts');
+ add_action('admin_print_styles-' . $page_main, 'duplicator_styles' );
+ add_action('admin_print_styles-' . $page_diag, 'duplicator_styles' );
+ add_action('admin_print_styles-' . $page_about, 'duplicator_styles' );
+ add_action('admin_print_styles-' . $page_support, 'duplicator_styles' );
+ }
+
+ /**
+ * DUPLICATOR_SCRIPTS
+ * Loads the required javascript libs only for this plugin */
+ function duplicator_scripts() {
+ wp_enqueue_script("jquery-ui", DUPLICATOR_PLUGIN_URL . "js/jquery-ui.min.js", array( 'jquery' ), "1.8.21");
+ }
+
+ /**
+ * DUPLICATOR_STYLES
+ * Loads the required css links only for this plugin */
+ function duplicator_styles() {
+ wp_enqueue_style('jquery-ui');
+ wp_enqueue_style('duplicator_style');
+ }
+
+ /**
+ * DUPLICATOR_MANAGE_LINK
+ * Adds the manage link in the plugins list */
+ function duplicator_manage_link($links, $file) {
+ static $this_plugin;
+ if (!$this_plugin) $this_plugin = plugin_basename(__FILE__);
+
+ if ($file == $this_plugin){
+ $settings_link = ''. __("Manage", 'wpduplicator') .'';
+ array_unshift($links, $settings_link);
+ }
+ return $links;
+ }
+
+ //Use WordPress Debugging log file. file is written to wp-content/debug.log
+ //trace with tail command to see real-time issues.
+ if(!function_exists('duplicator_debug')){
+ function duplicator_debug( $message ) {
+ if( WP_DEBUG === true ){
+ if( is_array( $message ) || is_object( $message ) ){
+ error_log( print_r( $message, true ) );
+ } else {
+ error_log( $message );
+ }
+ }
+ }
+ }
+
+}
+?>
\ No newline at end of file