Esempio n. 1
0
/**
 *  DUPLICATOR_SYSTEM_DIRECTORY
 *  Returns the directory size and file count for the root directory minus
 *  any of the filters
 *  
 *  @return json   size and file count of directory
 */
function duplicator_system_directory()
{
    $json = array();
    $dirInfo = duplicator_dirInfo(rtrim(duplicator_safe_path(DUPLICATOR_WPROOTPATH), '/'));
    $dirSizeFormat = duplicator_bytesize($dirInfo['size']) or "0";
    $dirCountFormat = number_format($dirInfo['count']) or "unknown";
    $dirFolderFormat = number_format($dirInfo['folders']) or "unknown";
    $json['size'] = $dirSizeFormat;
    $json['count'] = $dirCountFormat;
    $json['folders'] = $dirFolderFormat;
    $json['flag'] = $dirInfo['flag'];
    die(json_encode($json));
}
Esempio n. 2
0
/**
 *  DUPLICATOR_CREATE_DBSCRIPT
 *  Create the SQL DataDump File
 *  @param string $destination		The full path and filname where the sql script will be written
 */
function duplicator_create_dbscript($destination)
{
    try {
        global $wpdb;
        $time_start = DuplicatorUtils::GetMicrotime();
        $handle = fopen($destination, 'w+');
        $tables = $wpdb->get_col('SHOW TABLES');
        $sql_header = "/* DUPLICATOR MYSQL SCRIPT CREATED ON : " . @date("F j, Y, g:i a") . " */\n\n";
        $sql_header .= "SET FOREIGN_KEY_CHECKS = 0;\n\n";
        @fwrite($handle, $sql_header);
        //BUILD CREATES:
        //All creates must be created before inserts do to foreign key constraints
        foreach ($tables as $table) {
            //$sql_del = ($GLOBALS['duplicator_opts']['dbadd_drop']) ? "DROP TABLE IF EXISTS {$table};\n\n" : "";
            //@fwrite($handle, $sql_del);
            $create = $wpdb->get_row("SHOW CREATE TABLE `{$table}`", ARRAY_N);
            @fwrite($handle, "{$create[1]};\n\n");
        }
        //BUILD INSERTS:
        //Create Insert in 100 row increments to better handle memory
        foreach ($tables as $table) {
            $row_count = $wpdb->get_var("SELECT Count(*) FROM `{$table}`");
            duplicator_log("{$table} ({$row_count})");
            if ($row_count > 100) {
                $row_count = ceil($row_count / 100);
            } else {
                if ($row_count > 0) {
                    $row_count = 1;
                }
            }
            if ($row_count >= 1) {
                @fwrite($handle, "\n/* INSERT TABLE DATA: {$table} */\n");
            }
            for ($i = 0; $i < $row_count; $i++) {
                $sql = "";
                $limit = $i * 100;
                $query = "SELECT * FROM `{$table}` LIMIT {$limit}, 100";
                $rows = $wpdb->get_results($query, ARRAY_A);
                if (is_array($rows)) {
                    foreach ($rows as $row) {
                        $sql .= "INSERT INTO `{$table}` VALUES(";
                        $num_values = count($row);
                        $num_counter = 1;
                        foreach ($row as $value) {
                            if (is_null($value) || !isset($value)) {
                                $num_values == $num_counter ? $sql .= 'NULL' : ($sql .= 'NULL, ');
                            } else {
                                $num_values == $num_counter ? $sql .= '"' . @mysql_real_escape_string($value) . '"' : ($sql .= '"' . @mysql_real_escape_string($value) . '", ');
                            }
                            $num_counter++;
                        }
                        $sql .= ");\n";
                    }
                    @fwrite($handle, $sql);
                    duplicator_fcgi_flush();
                }
            }
        }
        unset($sql);
        $sql_footer = "\nSET FOREIGN_KEY_CHECKS = 1;";
        @fwrite($handle, $sql_footer);
        duplicator_log("SQL CREATED: {$destination}");
        fclose($handle);
        $wpdb->flush();
        $time_end = DuplicatorUtils::GetMicrotime();
        $time_sum = DuplicatorUtils::ElapsedTime($time_end, $time_start);
        $sql_file_size = filesize($destination);
        if ($sql_file_size <= 0) {
            duplicator_error("ERROR: SQL file generated zero bytes.  \nERROR INFO: No data was written to the sql file.  Check permission on file and parent directory at [{$destination}]");
        }
        duplicator_log("SQL FILE SIZE: " . duplicator_bytesize($sql_file_size));
        duplicator_log("SQL RUNTIME: {$time_sum}");
    } catch (Exception $e) {
        duplicator_error("ERROR: Runtime error in duplicator_create_dbscript  \nERROR INFO: '{$e}'");
    }
}
?>
</td>
						</tr>
						<tr valign="top">
							<td><?php 
_e('Free space', 'hyper-cache');
?>
</td>
							<td><?php 
echo $perc;
?>
% -- <?php 
echo duplicator_bytesize($space_free);
?>
 from <?php 
echo duplicator_bytesize($space);
?>
<br/>
								 <small>
									 <?php 
_e("Note: This value is the physical servers hard-drive allocation.", 'wpduplicator');
?>
 <br/>
									 <?php 
_e("On shared hosts check your control panel for the 'TRUE' disk space quota value.", 'wpduplicator');
?>
									  
								 </small>
							</td>
						</tr>						   
				   </tbody>
			<tr>
				<?php 
if ($total_elements == 0) {
    ?>
					<th colspan="8">&nbsp;</th>
				<?php 
} else {
    ?>
	
					<th colspan="8" style='text-align:right; font-size:12px'>						
						<?php 
    echo _e("Packages", 'wpduplicator') . ': ' . $total_elements;
    ?>
 |
						<?php 
    echo _e("Total Size", 'wpduplicator') . ': ' . duplicator_bytesize($total_size);
    ?>
 
					</th>
				<?php 
}
?>
	
			</tr>
		</tfoot>
	</table>
</form>
</div>

<form id="dup-paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank" style="display:none"> 
	<input name="cmd" type="hidden" value="_s-xclick" /> 
 /**
  *  DUPLICATOR ZIP
  *  Creates the zip file
  *
  *  @param string $zipFilePath	The full path to the zip file that will be made
  *  @param string $folderPath	The folder that will be zipped
  *  @param string $sqlfilepath	The path to the database file to include in the package
  */
 function __construct($zipFilePath, $folderPath, $sqlfilepath)
 {
     try {
         $total_time_start = DuplicatorUtils::GetMicrotime();
         duplicator_log("PACKAGE DIR:  {$folderPath}");
         duplicator_log("PACKAGE FILE: {$zipFilePath}");
         $this->zipArchive = new ZipArchive();
         $this->zipFilePath = duplicator_safe_path($zipFilePath);
         $this->rootFolder = rtrim(duplicator_safe_path($folderPath), '/');
         $this->skipNames = $GLOBALS['duplicator_skip_ext-array'];
         $this->countDirs = 0;
         $this->countFiles = 0;
         $this->countLinks = 0;
         $exts_list = implode(";", $this->skipNames);
         $path_list = implode(";", $GLOBALS['duplicator_bypass-array']);
         $this->fileExtActive = strlen($exts_list);
         duplicator_log("FILTER EXTENSIONS:  '{$exts_list}'");
         duplicator_log("FILTER DIRECTORIES: '{$path_list}'");
         duplicator_log($GLOBALS['DUPLICATOR_SEPERATOR2']);
         //CREATE ZIP FILE
         if ($this->zipArchive->open($this->zipFilePath, ZIPARCHIVE::CREATE) === TRUE) {
             duplicator_log("STARTING PACKAGE BUILD");
         } else {
             duplicator_error("ERROR: Cannot open zip file with PHP ZipArchive.  \nERROR INFO: Path location [{$this->zipFilePath}]");
         }
         //ADD SQL File
         $sql_in_zip = $this->zipArchive->addFile($sqlfilepath, "/database.sql");
         if ($sql_in_zip) {
             duplicator_log("ADDED=>SQL: {$sqlfilepath}");
         } else {
             duplicator_error("ERROR: Unable to add database.sql file to package from.  \nERROR INFO: SQL File Path [{$sqlfilepath}]");
         }
         //RECURSIVE CALL TO ALL FILES
         $list_time_start = DuplicatorUtils::GetMicrotime();
         duplicator_log("BUILDING FILE LIST");
         $this->resursiveZip($this->rootFolder);
         $list_time_end = DuplicatorUtils::GetMicrotime();
         $list_time_sum = DuplicatorUtils::ElapsedTime($list_time_end, $list_time_start);
         duplicator_log("FILE LIST COMPLETE: {$list_time_sum}");
         duplicator_log("FILE LIST STATS: Dirs {$this->countDirs} | Files {$this->countFiles} | Links {$this->countLinks} | ");
         duplicator_log("\nPACKAGE INFO: " . print_r($this->zipArchive, true));
         //LOG FINAL RESULTS
         duplicator_log("CREATING PACKAGE");
         duplicator_fcgi_flush();
         @set_time_limit(0);
         $zip_close_result = $this->zipArchive->close();
         if ($zip_close_result) {
             duplicator_log("CLOSING PACKAGE RESULT: '{$zip_close_result}'");
         } else {
             $err_info = 'This server or hosted segement might have a disk quota limit.\\nPlease check your disk space usage to make sure you can store this zip file successfully.';
             duplicator_error("ERROR: ZipArchive Class did not close successfully.   \nERROR INFO: {$err_info}");
         }
         $total_time_end = DuplicatorUtils::GetMicrotime();
         $total_time_sum = DuplicatorUtils::ElapsedTime($total_time_end, $total_time_start);
         $this->zipFileSize = @filesize($this->zipFilePath);
         duplicator_log("PACKAGE FILE SIZE: " . duplicator_bytesize($this->zipFileSize));
         duplicator_log("PACKAGE RUNTIME: {$total_time_sum}");
     } catch (Exception $e) {
         duplicator_error("ERROR: Runtime error in class.zip.php constructor.   \nERROR INFO: {$e}");
     }
 }
Esempio n. 6
0
    $msg6 = __("This window should remain open for the process to complete", 'wpduplicator');
    $msg7 = __("Please be patient while we work through this Beta version", 'wpduplicator');
    $msg8 = __("Please report any issues to", 'wpduplicator');
    echo "<tr>\r\r\n\t\t\t\t\t\t<td colspan='7'>\r\r\n\t\t\t\t\t\t\t<div style='padding:60px 20px;text-align:center'>\r\r\n\t\t\t\t\t\t\t\t<b style='font-size:14px'>{$msg1}.<br/> {$msg2} <input type='submit' class='btn-create-pack'  ondblclick='javascript:return void(0);' value=''  /><br/> {$msg3}.</b><br/><br/>\r\r\n\t\t\t\t\t\t\t\t<i>{$msg4}.<br/> {$msg5}.<br/> {$msg6}. <br/><br/> {$msg7}.<br/> {$msg8} <a href='http://support.lifeinthegrid.com' target='_blank'>support.lifeinthegrid.com</a></i>\r\r\n\t\t\t\t\t\t\t</div>\r\r\n\t\t\t\t\t\t\t</td>\r\r\n\t\t\t\t\t\t</tr>";
}
?>

			<tfoot>
				<tr>
					<?php 
if ($total_elements == 0) {
    ?>

						<th colspan="8">&nbsp;</th>
					<?php 
} else {
    ?>
	
						<th colspan="8" style='text-align:right; font-size:12px'><?php 
    echo _e("Total Storage Used", 'wpduplicator') . ': ' . duplicator_bytesize($total_size);
    ?>
</th>
					<?php 
}
?>
	
				</tr>
			</tfoot>
		</table>
	</form>
</div>