web/wp-content/plugins/duplicator/inc/actions.php
author Anthony Ly <anthonyly.com@gmail.com>
Tue, 12 Mar 2013 18:21:39 +0100
changeset 206 919b4ddb13fa
parent 204 09a1c134465b
permissions -rw-r--r--
modification logo footer cccb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
195
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
     1
<?php
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
     2
/**
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
     3
 *  DUPLICATOR_CREATE
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
     4
 *  Creates the zip file, database entry, and installer file for the
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
     5
 *  new culmination of a 'Package Set'
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
     6
 *
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
     7
 *  @return string   A message about the action
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
     8
 *		- log:act__create=>done
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
     9
 */
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    10
function duplicator_create() {
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    11
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    12
	global $wp_version;
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    13
	global $wpdb;
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    14
	global $current_user;
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    15
	
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    16
	$packname = isset($_POST['package_name']) ? trim($_POST['package_name']) : null;
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    17
	
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    18
	$secure_token  = uniqid() . mt_rand(1000, 9999);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    19
	$uniquename    = "{$secure_token}_{$packname}";
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    20
	foreach(glob(DUPLICATOR_SSDIR_PATH . '/*.log') as $log_file){
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    21
		@unlink($log_file);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    22
	}
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    23
	
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    24
	$logfilename = "{$uniquename}.log";
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    25
	$GLOBALS['duplicator_package_log_handle'] = @fopen(DUPLICATOR_SSDIR_PATH . "/{$logfilename}", "c+");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    26
	
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    27
	duplicator_log("*********************************************************");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    28
	duplicator_log("PACKAGE-LOG: ");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    29
	duplicator_log("*********************************************************");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    30
	duplicator_log("duplicator: " . DUPLICATOR_VERSION);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    31
	duplicator_log("wordpress: {$wp_version}");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    32
	duplicator_log("php: " .  phpversion());
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    33
	duplicator_log("php sapi: " .  php_sapi_name());
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    34
	duplicator_log("server: {$_SERVER['SERVER_SOFTWARE']}");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    35
	duplicator_log("browser: {$_SERVER['HTTP_USER_AGENT']}");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    36
	duplicator_log("package name: {$packname}");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    37
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    38
	if($packname) {
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    39
		
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    40
		$max_time   = @ini_set("max_execution_time", $GLOBALS['duplicator_opts']['max_time']); 
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    41
		$max_memory = @ini_set('memory_limit', $GLOBALS['duplicator_opts']['max_memory']);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    42
		$max_time   = ($max_time === false)   ? "Unabled to set max_execution_time"  : "from={$max_time} to={$GLOBALS['duplicator_opts']['max_time']}";
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    43
		$max_memory = ($max_memory === false) ? "Unabled to set memory_limit"		 : "from={$max_memory} to={$GLOBALS['duplicator_opts']['max_memory']}";
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    44
		
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    45
		@set_time_limit(0);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    46
		duplicator_log("max_time: {$max_time}");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    47
		duplicator_log("max_memory: {$max_memory}");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    48
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    49
		$zipfilename  = "{$uniquename}_package.zip";
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    50
		$sqlfilename  = "{$uniquename}_database.sql";
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    51
		$exefilename  = "{$uniquename}_installer.php";
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    52
		
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    53
		$zipfilepath  = DUPLICATOR_SSDIR_PATH . "/{$zipfilename}";
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    54
		$sqlfilepath  = DUPLICATOR_SSDIR_PATH . "/{$sqlfilename}";
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    55
		$exefilepath  = DUPLICATOR_SSDIR_PATH . "/{$exefilename}";
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    56
		$zipsize 	  = 0;
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    57
		
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    58
		duplicator_log("mysql wait_timeout: {$GLOBALS['duplicator_opts']['max_time']}");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    59
		$wpdb->query("SET session wait_timeout = {$GLOBALS['duplicator_opts']['max_time']}");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    60
		
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    61
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    62
		duplicator_log("*********************************************************");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    63
		duplicator_log("SQL SCRIPT");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    64
		duplicator_log("*********************************************************");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    65
		duplicator_create_dbscript($sqlfilepath);		
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    66
		
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    67
		
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    68
		//CREATE ZIP ARCHIVE
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    69
		duplicator_log("*********************************************************");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    70
		duplicator_log("ZIP ARCHIVE");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    71
		duplicator_log("*********************************************************");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    72
		
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    73
		$zip = new Duplicator_Zip($zipfilepath, rtrim(DUPLICATOR_WPROOTPATH, '/'), $sqlfilepath);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    74
		$zipsize = filesize($zipfilepath);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    75
			
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    76
		($zipsize == false) 
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    77
			? duplicator_log("log:act__create=>warning: zipsize is unknown.")
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    78
			: duplicator_log("log:act__create=>zip file size is: " . duplicator_bytesize($zipsize));
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    79
	
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    80
		duplicator_log("log:act__create=>zip archive complete.", 2);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    81
		
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    82
		//Serlized settings
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    83
		$settings = array('plugin_version' => DUPLICATOR_VERSION,
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    84
						  'type' 		   => 'Manual');
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    85
		$serialized_settings = serialize($settings);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    86
		
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    87
		//Record archive info to database
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    88
		 $results = $wpdb->insert($wpdb->prefix . "duplicator", 
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    89
						array(
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    90
						      'token'    => $secure_token, 
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    91
							  'packname' => $packname, 
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    92
							  'zipname'  => $zipfilename, 
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    93
							  'zipsize'  => $zipsize, 
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    94
							  'created'  => current_time('mysql', get_option('gmt_offset')),
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    95
							  'owner'    => $current_user->user_login,
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    96
							  'settings' => "{$serialized_settings}") 
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    97
						);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    98
		if ($wpdb->insert_id) {
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    99
			duplicator_log("log:act__create=>recorded archieve id: " . $wpdb->insert_id);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   100
		} else {
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   101
			duplicator_log("log:act__create=>unable to record to database.");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   102
		}
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   103
		$wpdb->flush();
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   104
			
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   105
	
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   106
		//UPDATE INSTALL FILE
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   107
		duplicator_log("*********************************************************");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   108
		duplicator_log("UPDATE INSTALLER FILE");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   109
		duplicator_log("*********************************************************");
204
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 195
diff changeset
   110
		duplicator_build_installerFile();
195
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   111
		duplicator_create_installerFile($uniquename);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   112
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   113
		//SEND EMAIL
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   114
		//TODO: Send only SQL File via mail.  Zip files can get too large
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   115
		if( $GLOBALS['duplicator_opts']['email-me'] == "1" ) {
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   116
			duplicator_log("log:act__create=>email started");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   117
			$status      = ($zipsize) ? 'Success' : 'Failure';
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   118
			$attachments = ""; //array(DUPLICATOR_SSDIR_PATH . '/' . $packname .'.zip');
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   119
			$headers = 'From: Duplicator Plugin <no-reply@lifeinthegrid.com>' ."\r\n";
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   120
			$subject = "Package '{$packname}' completed";
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   121
			$message = "Run Status: {$status}\n\rSite Name: " . get_bloginfo('name') . "\n\rPackage Name: {$packname} \n\rCompleted at: " .current_time('mysql',get_option('gmt_offset'))  ;
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   122
			wp_mail($current_user->user_email, $subject, $message, $headers, $attachments);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   123
			duplicator_log("log:act__create=>sent email to: {$current_user->user_email}");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   124
			$other_emails = @preg_split("/[,;]/",  $GLOBALS['duplicator_opts']['email_others']);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   125
			if (count($other_emails)) {
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   126
				wp_mail($other_emails, $subject, $message, $headers, $attachments);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   127
				duplicator_log("log:act__create=>other emails sent: {$GLOBALS['duplicator_opts']['email_others']}");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   128
			}
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   129
			duplicator_log("log:act__create=>email finished");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   130
		}
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   131
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   132
	} 
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   133
	
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   134
	duplicator_log("*********************************************************");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   135
	duplicator_log("DONE PROCESSING => {$packname}");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   136
	duplicator_log("*********************************************************");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   137
	@fclose($GLOBALS['duplicator_package_log_handle']);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   138
	die();
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   139
}
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   140
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   141
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   142
/**
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   143
 *  DUPLICATOR_DELETE
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   144
 *  Deletes the zip file and database record entries for the
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   145
 *  selected ids.  Supports 1 to many deletes
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   146
 *
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   147
 *  @return string   A message about the action.  
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   148
 *		- see: duplicator_unlink
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   149
 */
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   150
function duplicator_delete() {
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   151
	try
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   152
	{
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   153
		$uniqueid = isset($_POST['duplicator_delid']) ? trim($_POST['duplicator_delid']) : null;
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   154
		if ($uniqueid != null) {
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   155
			$unique_list = explode(",", $uniqueid);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   156
			foreach ($unique_list as $id) {
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   157
				$msg  = duplicator_unlink($id);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   158
			}
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   159
		}
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   160
		die($msg);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   161
	}  
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   162
	catch(Exception $e) 
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   163
	{
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   164
		die("log:fun__delete=>runtime error: " . $e);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   165
	}
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   166
}
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   167
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   168
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   169
/**
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   170
 *  DUPLICATOR_SYSTEM_CHECK
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   171
 *  Check to see if the package already exsits or required files
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   172
 *  are installed.  Also check for package size
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   173
 *  
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   174
 *  @return string   A message about the action
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   175
 *		- log:act__system_check=>create new package
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   176
 *		- log:act__system_check=>overwrite
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   177
 */
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   178
function duplicator_system_check() {
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   179
	global $wpdb;
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   180
	
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   181
	@set_time_limit($GLOBALS['duplicator_opts']['max_time']);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   182
	duplicator_init_snapshotpath();
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   183
	
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   184
	$json = array();
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   185
		
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   186
	//SYS-100: FILE PERMS
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   187
	$test = is_readable(DUPLICATOR_WPROOTPATH)
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   188
			&& is_writeable(DUPLICATOR_SSDIR_PATH)
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   189
			&& is_writeable(DUPLICATOR_PLUGIN_PATH . 'files/')
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   190
			&& is_writeable(DUPLICATOR_PLUGIN_PATH . 'files/installer.rescue.php');
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   191
	$json['SYS-100'] = ($test) ? 'Pass' : 'Fail';
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   192
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   193
	//SYS-101 RESERVED FILE
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   194
	$phpFile = file_exists(DUPLICATOR_WPROOTPATH . DUPLICATOR_INSTALL_PHP) ? DUPLICATOR_INSTALL_PHP : "";
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   195
	$sqlFile = file_exists(DUPLICATOR_WPROOTPATH . DUPLICATOR_INSTALL_SQL) ? DUPLICATOR_INSTALL_SQL : "";
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   196
	$logFile = file_exists(DUPLICATOR_WPROOTPATH . DUPLICATOR_INSTALL_LOG) ? DUPLICATOR_INSTALL_LOG : "";
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   197
	$test = ! (strlen($phpFile) || strlen($sqlFile ) || strlen($logFile));
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   198
	$json['SYS-101'] = ($test) ? 'Pass' : 'Fail';
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   199
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   200
	//SYS-102 ZIP-ARCHIVE
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   201
	$test = class_exists('ZipArchive');
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   202
	$json['SYS-102'] = ($test) ? 'Pass' : 'Fail';
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   203
	
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   204
	//SYS-103 SAFE MODE
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   205
	$test = ini_get('safe_mode');;
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   206
	$json['SYS-103'] = ! ($test) ? 'Pass' : 'Fail';
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   207
	
204
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 195
diff changeset
   208
	//SYS-104 MYSQL SUPPORT
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 195
diff changeset
   209
	$mysql_test1 = function_exists('mysqli_connect');
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 195
diff changeset
   210
	$mysql_test2 = version_compare($wpdb->db_version(), '4.1', '>=' );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 195
diff changeset
   211
	$json['SYS-104'] = ($mysql_test1 && $mysql_test2) ? 'Pass' : 'Fail'; 
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 195
diff changeset
   212
	
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 195
diff changeset
   213
	//SYS-105 PHP VERSION
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 195
diff changeset
   214
	$test  = version_compare(phpversion(), '5.2.17');
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 195
diff changeset
   215
	$json['SYS-105'] = ($test >= 0) ? 'Pass' : 'Fail';
195
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   216
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   217
	$result = in_array('Fail', $json);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   218
	$json['Success'] = ! $result;
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   219
	
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   220
	die(json_encode($json));
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   221
}
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   222
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   223
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   224
/**
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   225
 *  DUPLICATOR_SYSTEM_DIRECTORY
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   226
 *  Returns the directory size and file count for the root directory minus
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   227
 *  any of the filters
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   228
 *  
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   229
 *  @return json   size and file count of directory
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   230
 */
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   231
function duplicator_system_directory() {
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   232
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   233
	$json = array();
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   234
	$dirInfo = duplicator_dirInfo(rtrim(duplicator_safe_path(DUPLICATOR_WPROOTPATH), '/'));
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   235
	$dirSizeFormat   = duplicator_bytesize($dirInfo['size']) or "0";
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   236
	$dirCountFormat  = number_format($dirInfo['count']) or "unknown";
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   237
	$dirFolderFormat = number_format($dirInfo['folders']) or "unknown";
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   238
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   239
	$json['size']    = $dirSizeFormat;
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   240
	$json['count']   = $dirCountFormat;
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   241
	$json['folders'] = $dirFolderFormat;
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   242
	$json['flag'] = $dirInfo['flag'];
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   243
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   244
	die(json_encode($json));
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   245
}
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   246
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   247
/**
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   248
 *  DUPLICATOR_UNLINK
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   249
 *  Removes the package
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   250
 *  
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   251
 *  @param string $file	 	The file name of the file to delete.
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   252
 *  @param string $path		The full path and file name of the file to delete
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   253
 *
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   254
 *  @return string   A message about the action
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   255
 *		- log:act__unlink=>removed
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   256
 *		- log:act__unlink=>file not found
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   257
 */
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   258
function duplicator_unlink($uniqueid) {
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   259
	try
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   260
	{
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   261
		$msg = "log:act__unlink=>file not found";
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   262
		if($uniqueid) {
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   263
			global $wpdb;
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   264
			$table_name = $wpdb->prefix . 'duplicator';
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   265
			if($wpdb->query("DELETE FROM {$table_name} WHERE zipname= '{$uniqueid}_package.zip'" ) != 0) {
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   266
				$msg = "log:act__unlink=>removed";
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   267
				try {
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   268
					@chmod(duplicator_safe_path(DUPLICATOR_SSDIR_PATH . "/{$uniqueid}_package.zip"), 0644);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   269
				    @chmod(duplicator_safe_path(DUPLICATOR_SSDIR_PATH . "/{$uniqueid}_database.sql"), 0644);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   270
					@unlink(duplicator_safe_path(DUPLICATOR_SSDIR_PATH . "/{$uniqueid}_package.zip"));
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   271
					@unlink(duplicator_safe_path(DUPLICATOR_SSDIR_PATH . "/{$uniqueid}_database.sql"));
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   272
					@unlink(duplicator_safe_path(DUPLICATOR_SSDIR_PATH . "/{$uniqueid}_installer.php"));
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   273
				}
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   274
				catch(Exception $e) {
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   275
					error_log(var_dump($e->getMessage()));
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   276
				}
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   277
			//Check for Legacy pre 0.3.1
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   278
			} else if($wpdb->query("DELETE FROM {$table_name} WHERE zipname= '{$uniqueid}'" ) != 0) {
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   279
				try {
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   280
					@chmod(duplicator_safe_path(DUPLICATOR_SSDIR_PATH . "/{$uniqueid}"), 0644);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   281
					@unlink(duplicator_safe_path(DUPLICATOR_SSDIR_PATH . "/{$uniqueid}"));
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   282
				} catch(Exception $e) {
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   283
					error_log(var_dump($e->getMessage()));
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   284
				}
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   285
			}
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   286
		}
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   287
		return $msg;
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   288
	}  
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   289
	catch(Exception $e) 
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   290
	{
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   291
		die("log:fun__unlink=>runtime error: " . $e);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   292
	}	
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   293
}
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   294
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   295
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   296
/**
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   297
 *  DUPLICATOR_SETTINGS
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   298
 *  Saves plugin settings
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   299
 *  
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   300
 *  @return string   A message about the action
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   301
 *		- log:act__settings=>saved
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   302
 */
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   303
function duplicator_settings(){
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   304
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   305
	//defaults
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   306
	add_option('duplicator_options', '');
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   307
	
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   308
	$skip_ext = str_replace(array(' ', '.'), "", $_POST['skip_ext']);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   309
	$by_pass_array = explode(";", $_POST['dir_bypass']);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   310
	$by_pass_clean = "";
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   311
	
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   312
	foreach ($by_pass_array as $val) {
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   313
		if (strlen($val) >= 2) {
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   314
			$by_pass_clean .= duplicator_safe_path(trim(rtrim($val, "/\\"))) . ";";
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   315
		}
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   316
	}
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   317
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   318
	if (is_numeric($_POST['max_memory'])) {
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   319
		$maxmem = $_POST['max_memory'] < 256 ? 256 : $_POST['max_memory'];
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   320
	} else {
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   321
		$maxmem = 256;
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   322
	}
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   323
	
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   324
	$duplicator_opts = array(
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   325
		'dbhost'		=>$_POST['dbhost'],
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   326
		'dbname'		=>$_POST['dbname'],
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   327
		'dbuser'		=>$_POST['dbuser'],
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   328
		'dbiconv'		=>$_POST['dbiconv'],
204
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 195
diff changeset
   329
		'url_new'			=>rtrim($_POST['url_new'], '/'),
195
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   330
		'email-me'		=>$_POST['email-me'],
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   331
		'email_others'	=>$_POST['email_others'],
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   332
		'max_time'		=>$_POST['max_time'],
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   333
		'max_memory'	=>preg_replace('/\D/', '', $maxmem) . 'M',
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   334
		'skip_ext'		=>str_replace(",", ";", $skip_ext),
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   335
		'dir_bypass'	=>$by_pass_clean,
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   336
		'log_level'		=>$_POST['log_level'],
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   337
		'rm_snapshot'	=>$_POST['rm_snapshot']);
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   338
		
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   339
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   340
	update_option('duplicator_options', serialize($duplicator_opts));
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   341
	
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   342
	die("log:act__settings=>saved");
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   343
}
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   344
//DO NOT ADD A CARRIAGE RETURN BEYOND THIS POINT (headers issue)!!
c7c0fbc09788 ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   345
?>