author | Anthony Ly <anthonyly.com@gmail.com> |
Wed, 19 Dec 2012 17:46:52 -0800 | |
changeset 204 | 09a1c134465b |
parent 195 | c7c0fbc09788 |
permissions | -rw-r--r-- |
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 |
/** |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
4 |
* DUPLICATOR_CREATE_DBSCRIPT |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
5 |
* Create the SQL DataDump File |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
6 |
* @param string $destination The full path and filname where the sql script will be written |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
7 |
*/ |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
8 |
function duplicator_create_dbscript($destination) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
9 |
try { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
10 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
11 |
global $wpdb; |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
12 |
//$dbiconv = ($GLOBALS['duplicator_opts']['dbiconv'] == "0" && function_exists("iconv")) ? false : true; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
13 |
|
195
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
14 |
$handle = fopen($destination,'w+'); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
15 |
$tables = $wpdb->get_col('SHOW TABLES'); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
16 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
17 |
duplicator_log("log:fun__create_dbscript=>started"); |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
18 |
//if ($dbiconv) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
19 |
//duplicator_log("log:fun__create_dbscript=>dbiconv enabled"); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
20 |
//} |
195
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
21 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
22 |
foreach ($tables as $table) { |
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 |
//Generate Drop Statement |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
25 |
//$sql_del = ($GLOBALS['duplicator_opts']['dbadd_drop']) ? "DROP TABLE IF EXISTS {$table};\n\n" : ""; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
26 |
//@fwrite($handle, $sql_del); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
27 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
28 |
//Generate Create Statement |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
29 |
$row_count = $wpdb->get_var("SELECT Count(*) FROM `{$table}`"); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
30 |
duplicator_log("start: {$table} ({$row_count})"); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
31 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
32 |
$create = $wpdb->get_row("SHOW CREATE TABLE `{$table}`", ARRAY_N); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
33 |
$sql_crt = "{$create[1]};\n\n"; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
34 |
@fwrite($handle, $sql_crt); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
35 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
36 |
if ($row_count > 100) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
37 |
$row_count = ceil($row_count / 100); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
38 |
} else if ($row_count > 0) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
39 |
$row_count = 1; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
40 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
41 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
42 |
//PERFORM ICONV ROUTINE |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
43 |
//Chunck the query results to avoid memory issues |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
44 |
/*if ($dbiconv) { |
195
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
45 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
46 |
for ($i = 0; $i < $row_count; $i++) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
47 |
$sql = ""; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
48 |
$limit = $i * 100; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
49 |
$query = "SELECT * FROM `{$table}` LIMIT {$limit}, 100"; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
50 |
$rows = $wpdb->get_results($query, ARRAY_A); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
51 |
if (is_array($rows)) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
52 |
foreach ($rows as $row) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
53 |
$sql .= "INSERT INTO `{$table}` VALUES("; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
54 |
$num_values = count($row); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
55 |
$num_counter = 1; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
56 |
foreach ($row as $value) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
57 |
$value = @iconv(DUPLICATOR_DB_ICONV_IN, DUPLICATOR_DB_ICONV_OUT, $value); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
58 |
($num_values == $num_counter) |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
59 |
? $sql .= '"' . @mysql_real_escape_string($value) . '"' |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
60 |
: $sql .= '"' . @mysql_real_escape_string($value) . '", '; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
61 |
$num_counter++; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
62 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
63 |
$sql .= ");\n"; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
64 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
65 |
@fwrite($handle, $sql); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
66 |
duplicator_fcgi_flush(); |
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 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
69 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
70 |
//DO NOT PERFORM ICONV |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
71 |
} else {*/ |
195
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 |
for ($i = 0; $i < $row_count; $i++) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
74 |
$sql = ""; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
75 |
$limit = $i * 100; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
76 |
$query = "SELECT * FROM `{$table}` LIMIT {$limit}, 100"; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
77 |
$rows = $wpdb->get_results($query, ARRAY_A); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
78 |
if (is_array($rows)) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
79 |
foreach ($rows as $row) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
80 |
$sql .= "INSERT INTO `{$table}` VALUES("; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
81 |
$num_values = count($row); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
82 |
$num_counter = 1; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
83 |
foreach ($row as $value) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
84 |
($num_values == $num_counter) |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
85 |
? $sql .= '"' . @mysql_real_escape_string($value) . '"' |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
86 |
: $sql .= '"' . @mysql_real_escape_string($value) . '", '; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
87 |
$num_counter++; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
88 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
89 |
$sql .= ");\n"; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
90 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
91 |
@fwrite($handle, $sql); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
92 |
duplicator_fcgi_flush(); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
93 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
94 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
95 |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
96 |
//} |
195
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 |
@fwrite($handle, "\n\n"); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
99 |
duplicator_log("done: {$table}"); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
100 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
101 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
102 |
duplicator_log("log:fun__create_dbscript=>sql file written to {$destination}"); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
103 |
fclose($handle); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
104 |
$wpdb->flush(); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
105 |
duplicator_log("log:fun__create_dbscript=>ended"); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
106 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
107 |
} catch(Exception $e) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
108 |
duplicator_log("log:fun__create_dbscript=>runtime error: " . $e); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
109 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
110 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
111 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
112 |
/** |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
113 |
* DUPLICATOR_BUILD_INSTALLERFILE |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
114 |
* Builds the Installer file from the contents of the files/installer directory |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
115 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
116 |
function duplicator_build_installerFile() { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
117 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
118 |
duplicator_log("log:fun__build_installerFile=>start"); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
119 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
120 |
$template_path = duplicator_safe_path(DUPLICATOR_PLUGIN_PATH . 'files/installer.template.php'); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
121 |
$main_path = duplicator_safe_path(DUPLICATOR_PLUGIN_PATH . 'files/installer/main.installer.php'); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
122 |
@chmod($template_path, 0777); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
123 |
@chmod($main_path, 0777); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
124 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
125 |
$main_data = file_get_contents("{$main_path}"); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
126 |
$template_result = file_put_contents($template_path, $main_data); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
127 |
if ($main_data === false || $template_result == false) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
128 |
duplicator_log("log:fun__build_installerFile=>install generation failed to copy {$main_path}"); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
129 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
130 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
131 |
$embeded_files = array ( |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
132 |
"inc.utils.php" => "@@INC.UTILS.PHP@@", |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
133 |
"ajax.step1.php" => "@@AJAX.STEP1.PHP@@", |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
134 |
"ajax.step2.php" => "@@AJAX.STEP2.PHP@@", |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
135 |
"inc.style.css" => "@@INC.STYLE.CSS@@", |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
136 |
"inc.scripts.js" => "@@INC.SCRIPTS.JS@@", |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
137 |
"view.step1.php" => "@@VIEW.STEP1.PHP@@", |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
138 |
"view.step2.php" => "@@VIEW.STEP2.PHP@@", |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
139 |
"view.step3.php" => "@@VIEW.STEP3.PHP@@"); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
140 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
141 |
foreach ($embeded_files as $name=>$token) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
142 |
$file_path = DUPLICATOR_PLUGIN_PATH . "files/installer/${name}"; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
143 |
@chmod($file_path, 0777); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
144 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
145 |
$search_data = @file_get_contents($template_path); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
146 |
$insert_data = @file_get_contents($file_path); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
147 |
file_put_contents($template_path, str_replace("${token}", "{$insert_data}", $search_data)); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
148 |
if ($search_data === false || $insert_data == false) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
149 |
duplicator_log("log:fun__build_installerFile=>install generation failed at {$token}"); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
150 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
151 |
@chmod($file_path, 0644); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
152 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
153 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
154 |
@chmod($template_path, 0644); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
155 |
@chmod($main_path, 0644); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
156 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
157 |
duplicator_log("log:fun__build_installerFile=>end"); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
158 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
159 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
160 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
161 |
/** |
195
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
162 |
* DUPLICATOR_CREATE_INSTALLERFILE |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
163 |
* Prep the Installer file for use. use %string% token for replacing |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
164 |
* @param string $uniquename The unique name this installer file will be associated with |
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 |
function duplicator_create_installerFile($uniquename) { |
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 |
duplicator_log("log:fun__create_installerFile=>started"); |
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 |
global $wpdb; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
171 |
$template = duplicator_safe_path(DUPLICATOR_PLUGIN_PATH . 'files/installer.template.php'); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
172 |
$installerRescue = duplicator_safe_path(DUPLICATOR_PLUGIN_PATH . 'files/installer.rescue.php'); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
173 |
$installerCore = duplicator_safe_path(DUPLICATOR_SSDIR_PATH) . "/{$uniquename}_installer.php"; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
174 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
175 |
$err_msg = "\n!!!WARNING!!! unable to read/write installer\nSee file:{$installerCore} \nPlease check permission and owner on file and parent folder."; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
176 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
177 |
get_option('duplicator_options') == "" ? "" : $duplicator_opts = unserialize(get_option('duplicator_options')); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
178 |
$replace_items = Array( |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
179 |
"fwrite_url_old" => get_option('siteurl'), |
195
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
180 |
"fwrite_package_name" => "{$uniquename}_package.zip", |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
181 |
"fwrite_secure_name" => "{$uniquename}", |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
182 |
"fwrite_url_new" => $duplicator_opts['url_new'], |
195
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
183 |
"fwrite_dbhost" => $duplicator_opts['dbhost'], |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
184 |
"fwrite_dbname" => $duplicator_opts['dbname'], |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
185 |
"fwrite_dbuser" => $duplicator_opts['dbuser'], |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
186 |
"fwrite_wp_tableprefix" => $wpdb->prefix, |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
187 |
"fwrite_blogname" => get_option('blogname'), |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
188 |
"fwrite_wproot" => DUPLICATOR_WPROOTPATH, |
195
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
189 |
"fwrite_rescue_flag" => ""); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
190 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
191 |
if( file_exists($template) && is_readable($template)) { |
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 |
$install_str = duplicator_parse_template($template, $replace_items); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
194 |
if (empty($install_str)) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
195 |
die(duplicator_log("log:fun__create_installerFile=>file-empty-read" . $err_msg)); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
196 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
197 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
198 |
//RESCUE FILE |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
199 |
$replace_items["fwrite_rescue_flag"] = '(rescue file)'; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
200 |
$rescue_str = duplicator_parse_template($template, $replace_items); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
201 |
$fp = fopen($installerRescue, (!file_exists($installerRescue)) ? 'x+' : 'w'); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
202 |
@fwrite($fp, $rescue_str, strlen($rescue_str)); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
203 |
@fclose($fp); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
204 |
$rescue_str = null; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
205 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
206 |
//INSTALLER FILE |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
207 |
if (!file_exists($installerCore)) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
208 |
$fp2 = fopen($installerCore, 'x+') or die(duplicator_log("log:fun__create_installerFile=>file-open-error-x" . $err_msg)); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
209 |
} else { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
210 |
$fp2 = fopen($installerCore, 'w') or die(duplicator_log("log:fun__create_installerFile=>file-open-error-w" . $err_msg)); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
211 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
212 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
213 |
if (fwrite($fp2, $install_str, strlen($install_str))) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
214 |
duplicator_log("log:fun__create_installerFile=>installer.php updated at: {$installerCore}"); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
215 |
} else { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
216 |
duplicator_log("log:fun__create_installerFile=>file-create-error" . $err_msg); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
217 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
218 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
219 |
@fclose($fp2); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
220 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
221 |
else |
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 |
die(duplicator_log("log:fun__create_installerFile=>Template missing or unreadable: '$template'")); |
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 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
226 |
duplicator_log("log:fun__create_installerFile=>ended"); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
227 |
} |
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 |
/** |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
230 |
* DUPLICATOR_PARSE_TEMPLATE |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
231 |
* Tokenize a file based on an array key |
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 |
* @param string $filename The filename to tokenize |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
234 |
* @param array $data The array of key value items to tokenize |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
235 |
*/ |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
236 |
function duplicator_parse_template($filename, $data) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
237 |
$q = file_get_contents($filename); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
238 |
foreach ($data as $key => $value) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
239 |
$q = str_replace('%'.$key.'%', $value, $q); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
240 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
241 |
return $q; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
242 |
} |
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 |
|
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 |
* DUPLICATOR_BYTESIZE |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
247 |
* Display human readable byte sizes |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
248 |
* @param string $size The size in bytes |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
249 |
*/ |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
250 |
function duplicator_bytesize($size) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
251 |
try { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
252 |
$units = array('B', 'KB', 'MB', 'GB', 'TB'); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
253 |
for ($i = 0; $size >= 1024 && $i < 4; $i++) $size /= 1024; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
254 |
return round($size, 2).$units[$i]; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
255 |
} catch (Exception $e) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
256 |
return "n/a"; |
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 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
259 |
|
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 |
* DUPLICATOR_DIRSIZE |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
262 |
* Get the directory size recursively, but don't calc the snapshot directory, exclusion diretories |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
263 |
* @param string $directory The directory to calculate |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
264 |
*/ |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
265 |
function duplicator_dirInfo($directory) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
266 |
try { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
267 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
268 |
$size = 0; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
269 |
$count = 0; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
270 |
$folders = 0; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
271 |
$flag = false; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
272 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
273 |
//EXCLUDE: Snapshot directory |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
274 |
$directory = duplicator_safe_path($directory); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
275 |
if( strstr($directory, DUPLICATOR_SSDIR_PATH)) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
276 |
return; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
277 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
278 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
279 |
//EXCLUDE: Directory Exclusions List |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
280 |
if ($GLOBALS['duplicator_bypass-array'] != null) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
281 |
foreach ($GLOBALS['duplicator_bypass-array'] as $val) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
282 |
if (duplicator_safe_path($val) == $directory) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
283 |
return; |
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 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
288 |
if ($handle = @opendir($directory)) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
289 |
while (false !== ($file = @readdir($handle))) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
290 |
if ($file != '.' && $file != '..') { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
291 |
$nextpath = $directory . '/' . $file; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
292 |
if (is_dir($nextpath)) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
293 |
$folders++; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
294 |
$result = duplicator_dirInfo($nextpath); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
295 |
$size += $result['size']; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
296 |
$count += $result['count']; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
297 |
$folders += $result['folders']; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
298 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
299 |
else if (is_file($nextpath) && is_readable($nextpath)) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
300 |
if(!in_array(@pathinfo($nextpath, PATHINFO_EXTENSION), $GLOBALS['duplicator_skip_ext-array'])) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
301 |
$fmod = @filesize($nextpath); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
302 |
if ($fmod === false) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
303 |
$flag = true; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
304 |
} else { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
305 |
$size += @filesize($nextpath); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
306 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
307 |
$count++; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
308 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
309 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
310 |
} |
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 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
313 |
closedir($handle); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
314 |
$total['size'] = $size; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
315 |
$total['count'] = $count; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
316 |
$total['folders'] = $folders; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
317 |
$total['flag'] = $flag; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
318 |
return $total; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
319 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
320 |
} catch(Exception $e) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
321 |
duplicator_log("log:fun__dirInfo=>runtime error: " . $e . "\nNOTE: Try excluding the stat failed to the Duplicators directory exclusion list or change the permissions."); |
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 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
325 |
/** |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
326 |
* DUPLICATOR_CREATE_SNAPSHOTPATH |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
327 |
* Creates the snapshot directory if it doesn't already exisit |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
328 |
*/ |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
329 |
function duplicator_init_snapshotpath() { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
330 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
331 |
$path_wproot = duplicator_safe_path(DUPLICATOR_WPROOTPATH); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
332 |
$path_ssdir = duplicator_safe_path(DUPLICATOR_SSDIR_PATH); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
333 |
$path_plugin = duplicator_safe_path(DUPLICATOR_PLUGIN_PATH); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
334 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
335 |
//-------------------------------- |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
336 |
//CHMOD DIRECTORY ACCESS |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
337 |
//wordpress root directory |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
338 |
@chmod($path_wproot , 0755); |
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 |
//snapshot directory |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
341 |
@mkdir($path_ssdir, 0755); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
342 |
@chmod($path_ssdir, 0755); |
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 |
//plugins dir/files |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
345 |
@chmod($path_plugin . 'files', 0755); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
346 |
@chmod(duplicator_safe_path($path_plugin . 'files/installer.rescue.php'), 0644); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
347 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
348 |
//-------------------------------- |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
349 |
//FILE CREATION |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
350 |
//SSDIR: Create Index File |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
351 |
$ssfile = @fopen($path_ssdir .'/index.php', 'w'); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
352 |
@fwrite($ssfile, '<?php error_reporting(0); if (stristr(php_sapi_name(), "fcgi")) { $url = "http://" . $_SERVER["HTTP_HOST"]; header("Location: {$url}/404.html");} else { header("HTML/1.1 404 Not Found", true, 404);} exit(); ?>'); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
353 |
@fclose($ssfile); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
354 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
355 |
//SSDIR: Create token file in snapshot |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
356 |
$tokenfile = @fopen($path_ssdir .'/dtoken.php', 'w'); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
357 |
@fwrite($tokenfile, '<?php error_reporting(0); if (stristr(php_sapi_name(), "fcgi")) { $url = "http://" . $_SERVER["HTTP_HOST"]; header("Location: {$url}/404.html");} else { header("HTML/1.1 404 Not Found", true, 404);} exit(); ?>'); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
358 |
@fclose($tokenfile); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
359 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
360 |
//SSDIR: Create .htaccess |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
361 |
$htfile = @fopen($path_ssdir .'/.htaccess', 'w'); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
362 |
@fwrite($htfile, "Options -Indexes"); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
363 |
@fclose($htfile); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
364 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
365 |
//SSDIR: Robots.txt file |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
366 |
$robotfile = @fopen($path_ssdir .'/robots.txt', 'w'); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
367 |
@fwrite($robotfile, "User-agent: * \nDisallow: /" . DUPLICATOR_SSDIR_NAME . '/'); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
368 |
@fclose($robotfile); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
369 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
370 |
//PLUG DIR: Create token file in plugin |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
371 |
$tokenfile2 = @fopen($path_plugin .'files/dtoken.php', 'w'); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
372 |
@fwrite($tokenfile2, '<?php @error_reporting(0); @require_once("../../../../wp-admin/admin.php"); global $wp_query; $wp_query->set_404(); header("HTML/1.1 404 Not Found", true, 404); header("Status: 404 Not Found"); @include(get_template_directory () . "/404.php"); ?>'); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
373 |
@fclose($tokenfile2); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
374 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
375 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
376 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
377 |
/** |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
378 |
* DUPLICATOR_SAFE_PATH |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
379 |
* Makes path safe for any OS |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
380 |
* Paths should ALWAYS READ be "/" |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
381 |
* uni: /home/path/file.xt |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
382 |
* win: D:/home/path/file.txt |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
383 |
* @param string $path The path to make safe |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
384 |
*/ |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
385 |
function duplicator_safe_path($path) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
386 |
return str_replace("\\", "/", $path); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
387 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
388 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
389 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
390 |
/** |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
391 |
* DUPLICATOR_FCGI_FLUSH |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
392 |
* PHP_SAPI for fcgi requires a data flush of at least 256 |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
393 |
* bytes every 40 seconds or else it forces a script hault |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
394 |
*/ |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
395 |
function duplicator_fcgi_flush() { |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
195
diff
changeset
|
396 |
echo(str_repeat(' ',264)); |
195
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
397 |
@flush(); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
398 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
399 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
400 |
/** |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
401 |
* DUPLICATOR_SNAPSHOT_URLPATH |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
402 |
* returns the snapshot url |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
403 |
*/ |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
404 |
function duplicator_snapshot_urlpath() { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
405 |
return get_site_url(null, '', is_ssl() ? 'https' : 'http') . '/' . DUPLICATOR_SSDIR_NAME . '/' ; |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
406 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
407 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
408 |
/** |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
409 |
* DUPLICATOR_LOG |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
410 |
* Centralized logging method |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
411 |
* @param string $msg The message to log |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
412 |
*/ |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
413 |
function duplicator_log($msg, $level = 0) { |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
414 |
$stamp = date('h:i:s'); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
415 |
@fwrite($GLOBALS['duplicator_package_log_handle'], "{$stamp} {$msg} \n"); |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
416 |
} |
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
417 |
|
c7c0fbc09788
ajout du plugin Duplicator
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
418 |
?> |