当前位置: 首页>>代码示例>>PHP>>正文


PHP pb_backupbuddy::flush方法代码示例

本文整理汇总了PHP中pb_backupbuddy::flush方法的典型用法代码示例。如果您正苦于以下问题:PHP pb_backupbuddy::flush方法的具体用法?PHP pb_backupbuddy::flush怎么用?PHP pb_backupbuddy::flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pb_backupbuddy的用法示例。


在下文中一共展示了pb_backupbuddy::flush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: upload

/**
 *	upload()
 *
 *	Processes uploaded backup file.
 *
 *	@return		array		True on upload success; false otherwise.
 */
function upload()
{
    Auth::require_authentication();
    if (isset($_POST['upload']) && $_POST['upload'] == 'local') {
        $path_parts = pathinfo($_FILES['file']['name']);
        if (strtolower(substr($_FILES['file']['name'], 0, 6)) == 'backup' && strtolower($path_parts['extension']) == 'zip') {
            if (move_uploaded_file($_FILES['file']['tmp_name'], basename($_FILES['file']['name']))) {
                pb_backupbuddy::alert('File Uploaded. Your backup was successfully uploaded.');
                return true;
            } else {
                pb_backupbuddy::alert('Sorry, there was a problem uploading your file.', true);
                return false;
            }
        } else {
            pb_backupbuddy::alert('Only properly named BackupBuddy zip archives with a zip extension may be uploaded.', true);
            return false;
        }
    }
    // DOWNLOAD FILE FROM STASH TO LOCAL.
    if (pb_backupbuddy::_POST('upload') == 'stash') {
        pb_backupbuddy::set_greedy_script_limits(true);
        /*
        echo '<pre>';
        print_r( $_POST );
        echo '</pre>';
        */
        $requestcore_file = dirname(dirname(dirname(__FILE__))) . '/lib/requestcore/requestcore.class.php';
        require_once $requestcore_file;
        $link = pb_backupbuddy::_POST('link');
        $destination_file = dirname(dirname(dirname(dirname(__FILE__)))) . '/' . basename(pb_backupbuddy::_POST('link'));
        $destination_file = substr($destination_file, 0, stripos($destination_file, '.zip') + 4);
        $_GET['file'] = basename($destination_file);
        $request = new RequestCore($link);
        $request->set_write_file($destination_file);
        echo '<div id="pb_importbuddy_working" style="padding: 20px;">Downloading backup from Stash to `' . $destination_file . '`...<br><br><img src="' . pb_backupbuddy::plugin_url() . '/images/loading_large.gif" title="Working... Please wait as this may take a moment..."><br><br></div>';
        pb_backupbuddy::flush();
        $response = $request->send_request(false);
        if ($response !== true) {
            pb_backupbuddy::alert('Error #8548459598. Unable to download file from Stash. You may manually download it and upload to the server via FTP.');
        } else {
            // No error.
            if (!file_exists($destination_file)) {
                pb_backupbuddy::alert('Error #34845745878. Stash returned a success but the backup file was not found locally. Check this server\'s directory write permissions. You may manually download it and upload to the server via FTP.');
            }
        }
        echo '<script type="text/javascript">jQuery("#pb_importbuddy_working").hide();</script>';
    }
}
开发者ID:mariakhair,项目名称:bootstrap,代码行数:55,代码来源:1.php

示例2: status

 /**
  *	self::status()
  *
  *	Logs data to a CSV file. Optional unique serial identifier.
  *	If a serial is passed then EVERYTHING will be logged to the specified serial file in addition to whatever (if anything) is logged to main status file.
  *	Always logs to main status file based on logging settings whether serial is passed or not.
  *
  *	@see self::get_status().
  *
  *	@param	string	$type		Valid types: error, warning, details, message
  *	@param	string	$text		Text message to log.
  *	@param	string	$serial		Optional. Optional unique identifier for this plugin's message. Status messages are unique per plugin so this adds an additional unique layer for retrieval.
  *								If self::$_status_serial has been set by set_status_serial() then it will override if $serial is blank.
  *	@return	null
  */
 public static function status($type, $message, $serial = '', $js_mode = false)
 {
     global $pb_backupbuddy_js_status;
     if (defined('PB_IMPORTBUDDY') || isset($pb_backupbuddy_js_status) && $pb_backupbuddy_js_status === true) {
         $status = pb_backupbuddy::$format->date(time()) . "\t" . sprintf("%01.2f", round(microtime(true) - pb_backupbuddy::$start_time, 2)) . "\t" . sprintf("%01.2f", round(memory_get_peak_usage() / 1048576, 2)) . "\t" . $type . "\t" . str_replace(chr(9), '   ', $message);
         $status = str_replace('\\', '/', $status);
         echo '<script type="text/javascript">pb_status_append("' . str_replace("\n", '\\n', str_replace('"', '&quot;', $status)) . '");</script>';
         //echo '<script type="text/javascript">pb_status_append(\'' . str_replace( '\'', '&#39;', $status ) . '\');</script>';
         /*
         USE WITH JAVASCRIPT IN PAGE:
         <script type="text/javascript">
         	function pb_status_append( status_string ) {
         		target_id = 'importbuddy_status'; // importbuddy_status or pb_backupbuddy_status
         		jQuery( '#' + target_id ).append( "\n" + status_string );
         		textareaelem = document.getElementById( target_id );
         		textareaelem.scrollTop = textareaelem.scrollHeight;
         	}
         </script>
         */
         pb_backupbuddy::flush();
         //return;
     }
     $delimiter = '|~|';
     if (self::$_status_serial != '' && $serial == '') {
         $serial = self::$_status_serial;
     }
     // Make sure we have a unique log serial for all logs for security.
     if (!isset(self::$options['log_serial']) || self::$options['log_serial'] == '') {
         self::$options['log_serial'] = self::random_string(15);
         self::save();
     }
     // Determine whether writing to main file.
     $write_main = false;
     if (self::$options['log_level'] == 0) {
         // No logging.
         $write_main = false;
     } elseif (self::$options['log_level'] == 1) {
         // Errors only.
         if ($type == 'error') {
             $write_main = true;
             self::log('[' . $serial . '] ' . $message, 'error');
         }
     } else {
         // Everything else.
         $write_main = true;
         self::log('[' . $serial . '] ' . $message, $type);
     }
     // Determine whether writing to serial file. Ignores log level.
     if ($serial != '') {
         $write_serial = true;
     } else {
         $write_serial = false;
     }
     // Return if not writing to any file.
     if ($write_main !== true && $write_serial !== true) {
         return;
     }
     // Calculate log directory.
     if (defined('PB_STANDALONE') && PB_STANDALONE === true) {
         $log_directory = ABSPATH . 'importbuddy/';
     } else {
         $log_directory = WP_CONTENT_DIR . '/uploads/pb_' . self::settings('slug') . '/';
     }
     // Prepare directory for log files. Return if unable to do so.
     if (true !== self::anti_directory_browsing($log_directory)) {
         // Unable to secure directory. Fail.
         self::alert('Unable to create / verify anti directory browsing measures for status file `' . $status_file . '`. Log not written for security.');
         return;
     }
     // Function for writing actual log CSV data. Used later.
     if (!function_exists('write_status_line')) {
         function write_status_line($file, $content_array, $delimiter)
         {
             $delimiter = '|~|';
             if (false !== ($file_handle = @fopen($file, 'a'))) {
                 // Append mode.
                 //fputcsv ( $file_handle , $content_array );
                 fwrite($file_handle, trim(implode($delimiter, $content_array)) . PHP_EOL);
                 fclose($file_handle);
             } else {
                 pb_backupbuddy::alert('Unable to open file handler for status file `' . $file . '`. Unable to write status log.');
             }
         }
     }
     $content_array = array(pb_backupbuddy::$format->localize_time(time()), sprintf("%01.2f", round(microtime(true) - self::$start_time, 2)), sprintf("%01.2f", round(memory_get_peak_usage() / 1048576, 2)), $type, str_replace(chr(9), '   ', $message));
//.........这里部分代码省略.........
开发者ID:jimlongo56,项目名称:bhouse,代码行数:101,代码来源:_pluginbuddy.php

示例3: status

 /**
  *	status()
  *
  *	Write a status line into an existing textarea created with the status_box() function.
  *
  *	@param			$type		string		message, details, error, or warning. Currently not in use.
  *	@param			$message	string		Message to append to the status box.
  *	@return			null
  */
 function status($type, $message)
 {
     pb_backupbuddy::status($type, $message);
     $status_lines = pb_backupbuddy::get_status('ms_import', true, true, true);
     // $serial = '', $clear_retrieved = true, $erase_retrieved = true, $hide_getting_status = false
     if ($status_lines !== false) {
         // Only add lines if there is status contents.
         foreach ($status_lines as $status_line) {
             $status_line[0] = pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time($status_line[0]));
             $status_line[1] .= 'sec';
             $status_line[2] .= 'MB';
             echo '<script type="text/javascript">jQuery( "#importbuddy_status" ).append( "\\n' . implode("\t", $status_line) . '");	textareaelem = document.getElementById( "importbuddy_status" );	textareaelem.scrollTop = textareaelem.scrollHeight;	</script>';
             pb_backupbuddy::flush();
         }
     }
     /*
     $message = htmlentities( addslashes( $message ) );
     $status = date( $this->_parent->_parent->_timestamp, time() ) . ': ' . $message;
     
     echo '<script type="text/javascript">jQuery( "#importbuddy_status" ).append( "\n' . $status . '");	textareaelem = document.getElementById( "importbuddy_status" );	textareaelem.scrollTop = textareaelem.scrollHeight;	</script>';
     pb_backupbuddy::flush();
     
     if ( $type == 'error' ) {
     	$this->log( $message, 'error' );
     } elseif ( $type == 'warning' ) {
     	$this->log( $message, 'warning' );
     } else {
     	$this->log( '[' . $type . ']' . $message, 'all' );
     }
     */
 }
开发者ID:jimlongo56,项目名称:bhouse,代码行数:40,代码来源:multisite_import.php

示例4: restore_file_restore

    public function restore_file_restore()
    {
        $success = false;
        pb_backupbuddy::$ui->ajax_header(true, false);
        // js, no padding
        ?>
		<script type="text/javascript">
			function pb_status_append( status_string ) {
				target_id = 'pb_backupbuddy_status'; // importbuddy_status or pb_backupbuddy_status
				if( jQuery( '#' + target_id ).length == 0 ) { // No status box yet so suppress.
					return;
				}
				jQuery( '#' + target_id ).append( "\n" + status_string );
				textareaelem = document.getElementById( target_id );
				textareaelem.scrollTop = textareaelem.scrollHeight;
			}
		</script>
		<?php 
        global $pb_backupbuddy_js_status;
        $pb_backupbuddy_js_status = true;
        echo pb_backupbuddy::status_box('Restoring . . .');
        echo '<div id="pb_backupbuddy_working" style="width: 100px;"><br><center><img src="' . pb_backupbuddy::plugin_url() . '/images/working.gif" title="Working... Please wait as this may take a moment..."></center></div>';
        pb_backupbuddy::set_status_serial('restore');
        global $wp_version;
        pb_backupbuddy::status('details', 'BackupBuddy v' . pb_backupbuddy::settings('version') . ' using WordPress v' . $wp_version . ' on ' . PHP_OS . '.');
        $archive_file = pb_backupbuddy::_GET('archive');
        // archive to extract from.
        $files = pb_backupbuddy::_GET('files');
        // file to extract.
        $files_array = explode(',', $files);
        $files = array();
        foreach ($files_array as $file) {
            if (substr($file, -1) == '/') {
                // If directory then add wildcard.
                $file = $file . '*';
            }
            $files[$file] = $file;
        }
        unset($files_array);
        $serial = backupbuddy_core::get_serial_from_file($archive_file);
        // serial of archive.
        foreach ($files as $file) {
            $file = str_replace('*', '', $file);
            // Remove any wildcard.
            if (file_exists(ABSPATH . $file) && is_dir(ABSPATH . $file)) {
                if (($file_count = @scandir(ABSPATH . $file)) && count($file_count) > 2) {
                    pb_backupbuddy::status('error', __('Error #9036. The destination directory being restored already exists and is NOT empty. The directory will not be restored to prevent inadvertently losing files within the existing directory. Delete existing directory first if you wish to proceed or restore individual files.', 'it-l10n-backupbuddy') . ' Existing directory: `' . ABSPATH . $file . '`.');
                    echo '<script type="text/javascript">jQuery("#pb_backupbuddy_working").hide();</script>';
                    pb_backupbuddy::flush();
                    pb_backupbuddy::$ui->ajax_footer();
                    die;
                }
            }
        }
        require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php';
        $zipbuddy = new pluginbuddy_zipbuddy(backupbuddy_core::getBackupDirectory());
        // Calculate temp directory & lock it down.
        $temp_dir = get_temp_dir();
        $destination = $temp_dir . 'backupbuddy-' . $serial;
        if (!file_exists($destination) && false === mkdir($destination, 0777, true)) {
            $error = 'Error #458485945: Unable to create temporary location.';
            pb_backupbuddy::status('error', $error);
            echo '<script type="text/javascript">jQuery("#pb_backupbuddy_working").hide();</script>';
            pb_backupbuddy::flush();
            pb_backupbuddy::$ui->ajax_footer();
            die;
        }
        // If temp directory is within webroot then lock it down.
        $temp_dir = str_replace('\\', '/', $temp_dir);
        // Normalize for Windows.
        $temp_dir = rtrim($temp_dir, '/\\') . '/';
        // Enforce single trailing slash.
        if (FALSE !== stristr($temp_dir, ABSPATH)) {
            // Temp dir is within webroot.
            pb_backupbuddy::anti_directory_browsing($destination);
        }
        unset($temp_dir);
        pb_backupbuddy::status('details', 'Extracting into temporary directory "' . $destination . '".');
        pb_backupbuddy::status('details', 'Files to extract: `' . htmlentities(pb_backupbuddy::_GET('files')) . '`.');
        // Make sure temp subdirectories exist.
        /*
        foreach( $files as $file => $null ) {
        	mkdir( $destination . '/' . basename( $file ), 0777, true );
        }
        */
        pb_backupbuddy::flush();
        $extract_success = true;
        $extract_result = $zipbuddy->extract(backupbuddy_core::getBackupDirectory() . $archive_file, $destination, $files);
        if (false === $extract_result) {
            // failed.
            pb_backupbuddy::status('error', 'Error #584984458b. Unable to extract.');
            $extract_success = false;
        } else {
            // success.
            // Verify all files/directories to be extracted exist in temp destination directory. If any missing then delete everything and bail out.
            foreach ($files as &$file) {
                $file = str_replace('*', '', $file);
                // Remove any wildcard.
                if (!file_exists($destination . '/' . $file)) {
                    // Cleanup.
//.........这里部分代码省略.........
开发者ID:netfor,项目名称:nextrading,代码行数:101,代码来源:ajax.php

示例5: status

 /**
  *	status()
  *
  *	Write a status line into an existing textarea created with the status_box() function.
  *
  *	@param			$type		string		message, details, error, or warning. Currently not in use.
  *	@param			$message	string		Message to append to the status box.
  *	@return			null
  */
 function status($type, $message)
 {
     pb_backupbuddy::status($type, $message);
     $status_lines = pb_backupbuddy::get_status('ms_import', true, true, true);
     // $serial = '', $clear_retrieved = true, $erase_retrieved = true, $hide_getting_status = false
     if ($status_lines !== false) {
         // Only add lines if there is status contents.
         foreach ($status_lines as $status_line) {
             $status_line[0] = pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time($status_line[0]));
             $status_line[1] .= 'sec';
             $status_line[2] .= 'MB';
             echo '<script type="text/javascript">jQuery( "#importbuddy_status" ).append( "\\n' . implode("\t", $status_line) . '");	textareaelem = document.getElementById( "importbuddy_status" );	textareaelem.scrollTop = textareaelem.scrollHeight;	</script>';
             pb_backupbuddy::flush();
         }
     }
 }
开发者ID:serker72,项目名称:T3S,代码行数:25,代码来源:multisite_import.php

示例6: deploy

    public function deploy()
    {
        pb_backupbuddy::$ui->ajax_header();
        pb_backupbuddy::load_script('jquery');
        echo '<div id="pb_backupbuddy_working" style="width: 100px; margin-bottom: 30px;"><br><center><img src="' . pb_backupbuddy::plugin_url() . '/images/working.gif" title="Working... Please wait as this may take a moment..."></center></div>';
        ?>
		
		
		<script>
		function pb_status_append( status_string ) {
			var win = window.dialogArguments || opener || parent || top;
			win.pb_status_append( status_string );
		}
		function pb_status_undourl( undo_url ) {
			var win = window.dialogArguments || opener || parent || top;
			win.pb_status_undourl( undo_url );
		}
		
		var win = window.dialogArguments || opener || parent || top;
		win.window.scrollTo(0,0);
		</script>
		
		
		<?php 
        global $pb_backupbuddy_js_status;
        $pb_backupbuddy_js_status = true;
        pb_backupbuddy::set_status_serial('deploy');
        $step = strip_tags(pb_backupbuddy::_GET('step'));
        if (!ctype_alnum($step)) {
            die('Error #8549845: Invalid step `' . htmlentities($step) . '`.');
        }
        $stepFile = pb_backupbuddy::plugin_path() . '/controllers/pages/deploy/_' . $step . '.php';
        if (!file_exists($stepFile)) {
            pb_backupbuddy::alert('Error #3298238. Invalid deploy step `' . htmlentities(pb_backupbuddy::_GET('step')) . '` (' . $step . ').');
            die;
        }
        require $stepFile;
        echo '<br><br><br>';
        echo '<script type="text/javascript">jQuery("#pb_backupbuddy_working").hide();</script>';
        pb_backupbuddy::$ui->ajax_footer();
        pb_backupbuddy::flush();
        die;
    }
开发者ID:adrianjonmiller,项目名称:animalhealth,代码行数:43,代码来源:ajax.php

示例7: backupbuddy_hourpad

		if( jQuery( '#' + target_id ).length == 0 ) { // No status box yet so suppress.
			return;
		}
		jQuery( '#' + target_id ).append( "\n" + message );
		textareaelem = document.getElementById( target_id );
		textareaelem.scrollTop = textareaelem.scrollHeight;
	}
	
	function backupbuddy_hourpad(n) { return ("0" + n).slice(-2); }
</script>
<?php 
$success = false;
global $pb_backupbuddy_js_status;
$pb_backupbuddy_js_status = true;
echo pb_backupbuddy::status_box('Restoring . . .');
echo '<div id="pb_backupbuddy_working" style="width: 100px;"><br><center><img src="' . pb_backupbuddy::plugin_url() . '/images/working.gif" title="Working... Please wait as this may take a moment..."></center></div>';
pb_backupbuddy::set_status_serial('restore');
global $wp_version;
pb_backupbuddy::status('details', 'BackupBuddy v' . pb_backupbuddy::settings('version') . ' using WordPress v' . $wp_version . ' on ' . PHP_OS . '.');
$archive_file = pb_backupbuddy::_GET('archive');
// archive to extract from.
require pb_backupbuddy::plugin_path() . '/classes/_restoreFiles.php';
$result = backupbuddy_restore_files::restore(backupbuddy_core::getBackupDirectory() . $archive_file, $files, $finalPath = ABSPATH);
echo '<script type="text/javascript">jQuery("#pb_backupbuddy_working").hide();</script>';
pb_backupbuddy::flush();
if (false === $result) {
} else {
}
pb_backupbuddy::$ui->ajax_footer();
pb_backupbuddy::$ui->ajax_footer();
die;
开发者ID:elephantcode,项目名称:elephantcode,代码行数:31,代码来源:restore_file_restore.php

示例8: restore

 public static function restore($archive_file, $files, $finalPath, &$zipbuddy = null)
 {
     if (!current_user_can(pb_backupbuddy::$options['role_access'])) {
         die('Error #473623. Access Denied.');
     }
     $serial = backupbuddy_core::get_serial_from_file($archive_file);
     // serial of archive.
     $success = false;
     foreach ($files as $file) {
         $file = str_replace('*', '', $file);
         // Remove any wildcard.
         if (file_exists($finalPath . $file) && is_dir($finalPath . $file)) {
             if (($file_count = @scandir($finalPath . $file)) && count($file_count) > 2) {
                 pb_backupbuddy::status('error', __('Error #9036. The destination directory being restored already exists and is NOT empty. The directory will not be restored to prevent inadvertently losing files within the existing directory. Delete existing directory first if you wish to proceed or restore individual files.', 'it-l10n-backupbuddy') . ' Existing directory: `' . $finalPath . $file . '`.');
                 return false;
             }
         }
     }
     if (null === $zipbuddy) {
         require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php';
         $zipbuddy = new pluginbuddy_zipbuddy(backupbuddy_core::getBackupDirectory());
     }
     // Calculate temp directory & lock it down.
     $temp_dir = get_temp_dir();
     $destination = $temp_dir . 'backupbuddy-' . $serial;
     if (!file_exists($destination) && false === mkdir($destination, 0777, true)) {
         $error = 'Error #458485945: Unable to create temporary location.';
         pb_backupbuddy::status('error', $error);
         return false;
     }
     // If temp directory is within webroot then lock it down.
     $temp_dir = str_replace('\\', '/', $temp_dir);
     // Normalize for Windows.
     $temp_dir = rtrim($temp_dir, '/\\') . '/';
     // Enforce single trailing slash.
     if (FALSE !== stristr($temp_dir, ABSPATH)) {
         // Temp dir is within webroot.
         pb_backupbuddy::anti_directory_browsing($destination);
     }
     unset($temp_dir);
     pb_backupbuddy::status('details', 'Extracting into temporary directory "' . $destination . '".');
     $prettyFilesList = array();
     foreach ($files as $fileSource => $fileDestination) {
         $prettyFilesList[] = $fileSource . ' => ' . $fileDestination;
     }
     pb_backupbuddy::status('details', 'Files to extract: `' . htmlentities(implode(', ', $prettyFilesList)) . '`.');
     unset($prettyFilesList);
     pb_backupbuddy::flush();
     // Do the actual extraction.
     $extract_success = true;
     if (false === $zipbuddy->extract($archive_file, $destination, $files)) {
         pb_backupbuddy::status('error', 'Error #584984458b. Unable to extract.');
         $extract_success = false;
     }
     if (true === $extract_success) {
         // Verify all files/directories to be extracted exist in temp destination directory. If any missing then delete everything and bail out.
         foreach ($files as &$file) {
             $file = str_replace('*', '', $file);
             // Remove any wildcard.
             if (!file_exists($destination . '/' . $file)) {
                 // Cleanup.
                 foreach ($files as $file) {
                     @trigger_error('');
                     // Clear out last error.
                     @unlink($destination . '/' . $file);
                     $last_error = error_get_last();
                     if (is_array($last_error)) {
                         pb_backupbuddy::status('error', $last_error['message'] . ' File: `' . $last_error['file'] . '`. Line: `' . $last_error['line'] . '`.');
                     }
                 }
                 pb_backupbuddy::status('error', 'Error #854783474. One or more expected files / directories missing.');
                 $extract_success = false;
                 break;
             }
         }
         unset($file);
         // Made it this far so files all exist. Move them all.
         foreach ($files as $file) {
             @trigger_error('');
             // Clear out last error.
             if (false === @rename($destination . '/' . $file, $finalPath . $file)) {
                 $last_error = error_get_last();
                 if (is_array($last_error)) {
                     //print_r( $last_error );
                     pb_backupbuddy::status('error', $last_error['message'] . ' File: `' . $last_error['file'] . '`. Line: `' . $last_error['line'] . '`.');
                 }
                 $error = 'Error #9035. Unable to move restored file `' . $destination . '/' . $file . '` to `' . $finalPath . $file . '`. Verify permissions on destination location & that the destination directory/file does not already exist.';
                 pb_backupbuddy::status('error', $error);
             } else {
                 $details = 'Moved `' . $destination . '/' . $file . '` to `' . $finalPath . $file . '`.<br>';
                 pb_backupbuddy::status('details', $details);
                 $success = true;
             }
         }
     }
     // end extract success.
     // Try to cleanup.
     if (file_exists($destination)) {
         if (false === pb_backupbuddy::$filesystem->unlink_recursive($destination)) {
             pb_backupbuddy::status('details', 'Unable to delete temporary holding directory `' . $destination . '`.');
//.........这里部分代码省略.........
开发者ID:FelixNong1990,项目名称:andy,代码行数:101,代码来源:_restoreFiles.php

示例9: _dump_php

 private function _dump_php($output_directory, $tables)
 {
     //, $base_dump_mode, $additional_excludes ) {
     $output_file = $output_directory . 'db_1.sql';
     pb_backupbuddy::status('details', 'mysqlbuddy: Preparing to run PHP mysqldump compatibility mode.');
     if (false === ($file_handle = fopen($output_file, 'a'))) {
         pb_backupbuddy::status('error', 'Error #9018: Database file is not creatable/writable. Check your permissions for file `' . $output_file . '` in directory `' . $output_directory . '`.');
         return false;
     }
     global $wpdb;
     if (!is_object($wpdb)) {
         pb_backupbuddy::status('error', 'WordPress database object $wpdb did not exist. This should not happen.');
         error_log('WordPress database object $wpdb did not exist. This should not happen. BackupBuddy Error #8945587973.');
         return false;
     }
     // Connect if not connected for importbuddy.
     if (!mysql_ping($wpdb->dbh)) {
         mysql_connect($this->_database_host, $this->_database_user, $this->_database_pass);
         mysql_select_db($this->_database_name);
     }
     $_count = 0;
     $insert_sql = '';
     global $wpdb;
     // Used later for checking that we are still connected to DB.
     // Iterate through all the tables to backup.
     // TODO: Future ability to break up DB exporting to multiple page loads if needed. Really still need this now that we have command line dump?
     foreach ($tables as $table_key => $table) {
         $create_table = mysql_query("SHOW CREATE TABLE `{$table}`");
         if ($create_table === false) {
             pb_backupbuddy::status('error', 'Unable to access and dump database table `' . $table . '`. Table may not exist. Skipping backup of this table.');
             //pb_backupbuddy::$classes['core']->mail_error( 'Error #4537384: Unable to access and dump database table `' . $table . '`. Table may not exist. Skipping backup of this table.' );
             continue;
             // Skip this iteration as accessing this table failed.
         }
         // Table creation text.
         $create_table_array = mysql_fetch_array($create_table);
         mysql_free_result($create_table);
         // Free memory.
         $insert_sql .= str_replace("\n", '', $create_table_array[1]) . ";\n";
         // Remove internal linebreaks; only put one at end.
         unset($create_table_array);
         // Disable keys for this table.
         $insert_sql .= "/*!40000 ALTER TABLE `{$table}` DISABLE KEYS */;\n";
         // Row creation text for all rows within this table.
         $table_query = mysql_query("SELECT * FROM `{$table}`") or pb_backupbuddy::status('error', 'Error #9001: Unable to read database table `' . $table . '`. Your backup will not include data from this table (you may ignore this warning if you do not need this specific data). This is due to the following error: ' . mysql_error());
         if ($table_query === false) {
             pb_backupbuddy::status('error', 'ERROR #85449745. Unable to retrieve data from table `' . $table . '`. This table may be corrupt (try repairing the database) or too large to hold in memory (increase mysql and/or PHP memory). Check your PHP error log for further errors which may provide further information. Not continuing database dump to insure backup integrity.');
             return false;
         }
         $num_fields = mysql_num_fields($table_query);
         while ($fetch_row = mysql_fetch_array($table_query)) {
             $insert_sql .= "INSERT INTO `{$table}` VALUES(";
             for ($n = 1; $n <= $num_fields; $n++) {
                 $m = $n - 1;
                 if ($fetch_row[$m] === NULL) {
                     $insert_sql .= "NULL, ";
                 } else {
                     $insert_sql .= "'" . mysql_real_escape_string($fetch_row[$m]) . "', ";
                 }
             }
             $insert_sql = substr($insert_sql, 0, -2);
             $insert_sql .= ");\n";
             fwrite($file_handle, $insert_sql);
             $insert_sql = '';
             // Help keep HTTP alive.
             $_count++;
             if ($_count >= 400) {
                 echo ' ';
                 pb_backupbuddy::flush();
                 $_count = 0;
             }
         }
         // End foreach $tables.
         // Re-enable keys for this table.
         $insert_sql .= "/*!40000 ALTER TABLE `{$table}` ENABLE KEYS */;\n";
         // testing: mysql_close( $wpdb->dbh );
         // Verify database is still connected and working properly. Sometimes mysql runs out of memory and dies in the above foreach.
         // No point in reconnecting as we can NOT trust that our dump was succesful anymore (it most likely was not).
         if (@mysql_ping($wpdb->dbh)) {
             // Still connected to database.
             mysql_free_result($table_query);
             // Free memory.
         } else {
             // Database not connected.
             pb_backupbuddy::status('error', __('ERROR #9026: The mySQL server went away unexpectedly during database dump. This is almost always caused by mySQL running out of memory. The backup integrity can no longer be guaranteed so the backup has been halted.') . ' ' . __('Last table dumped before database server went away: ') . '`' . $table . '`.');
             return false;
         }
         // Help keep HTTP alive.
         echo ' ';
         pb_backupbuddy::status('details', 'Dumped database table `' . $table . '`.');
         pb_backupbuddy::flush();
         //unset( $tables[$table_key] );
     }
     fclose($file_handle);
     unset($file_handle);
     pb_backupbuddy::status('details', __('Finished PHP based SQL dump method.', 'it-l10n-backupbuddy'));
     return true;
 }
开发者ID:heyjones,项目名称:crossfitpurpose,代码行数:98,代码来源:mysqlbuddy.php

示例10: repairbuddy

 public static function repairbuddy($output_file = '')
 {
     if (defined('PB_DEMO_MODE')) {
         echo 'Access denied in demo mode.';
         return;
     }
     if (!isset(pb_backupbuddy::$options)) {
         pb_backupbuddy::load();
     }
     $output = file_get_contents(pb_backupbuddy::plugin_path() . '/_repairbuddy.php');
     if (pb_backupbuddy::$options['importbuddy_pass_hash'] != '') {
         $output = preg_replace('/#PASSWORD#/', pb_backupbuddy::$options['importbuddy_pass_hash'], $output, 1);
         // Only replaces first instance.
     }
     $output = preg_replace('/#VERSION#/', pb_backupbuddy::settings('version'), $output, 1);
     // Only replaces first instance.
     if ($output_file == '') {
         // No file so output to browser.
         header('Content-Description: File Transfer');
         header('Content-Type: text/plain; name=repairbuddy.php');
         header('Content-Disposition: attachment; filename=repairbuddy.php');
         header('Expires: 0');
         header('Content-Length: ' . strlen($output));
         pb_backupbuddy::flush();
         echo $output;
         pb_backupbuddy::flush();
         // BE SURE TO die() AFTER THIS AND NOT OUTPUT TO BROWSER!
     } else {
         // Write to file.
         file_put_contents($output_file, $output);
     }
 }
开发者ID:adrianjonmiller,项目名称:animalhealth,代码行数:32,代码来源:core.php

示例11: cron_next_step

 function cron_next_step($spawn_cron = true, $future_offset = 0, $next_step_title = '')
 {
     // Internal cron (optional; disabled by default).
     if ('1' == pb_backupbuddy::$options['use_internal_cron']) {
         if ($future_offset > 0) {
             // Delay requsted.
             if ($future_offset > backupbuddy_core::adjustedMaxExecutionTime()) {
                 $future_offset = 5;
                 // If huge, try 5 sec.
             }
             sleep($future_offset);
         }
         $cron_url = site_url();
         $args = array('backupbuddy_cron_action' => 'process_backup', 'backupbuddy_serial' => $this->_backup['serial'], 'backupbuddy_time' => time(), 'backupbuddy_key' => pb_backupbuddy::$options['log_serial']);
         pb_backupbuddy::status('details', 'Attempting to bypass WordPress cron and use internal cron system calling `' . $cron_url . '`. Args: `' . print_r($args, true) . '`.');
         pb_backupbuddy::flush();
         $response = wp_remote_post($cron_url, array('method' => 'POST', 'timeout' => backupbuddy_core::adjustedMaxExecutionTime(), 'redirection' => 3, 'httpversion' => '1.0', 'blocking' => false, 'headers' => array(), 'body' => $args, 'cookies' => array()));
         pb_backupbuddy::status('details', 'Cron response: `' . print_r($response, true) . '`.');
         return;
     }
     if ('1' == pb_backupbuddy::$options['skip_spawn_cron_call']) {
         pb_backupbuddy::status('details', 'Advanced option to skip call to spawn cron enabled. Setting to skip spawn_cron() call.');
         $spawn_cron = false;
     }
     pb_backupbuddy::status('details', 'Scheduling Cron for `' . $this->_backup['serial'] . '`.');
     // Need to make sure the database connection is active. Sometimes it goes away during long bouts doing other things -- sigh.
     // This is not essential so use include and not require (suppress any warning)
     @(include_once pb_backupbuddy::plugin_path() . '/lib/wpdbutils/wpdbutils.php');
     if (class_exists('pluginbuddy_wpdbutils')) {
         global $wpdb;
         $dbhelper = new pluginbuddy_wpdbutils($wpdb);
         if (!$dbhelper->kick()) {
             pb_backupbuddy::status('error', __('Database Server has gone away, unable to schedule next backup step. The backup cannot continue. This is most often caused by mysql running out of memory or timing out far too early. Please contact your host.', 'it-l10n-backupbuddy'));
             pb_backupbuddy::status('haltScript', '');
             // Halt JS on page.
             return false;
         }
     } else {
         pb_backupbuddy::status('details', __('Database Server connection status unverified.', 'it-l10n-backupbuddy'));
     }
     // Schedule event.
     $cron_time = time() + $future_offset;
     $cron_args = array($this->_backup['serial']);
     pb_backupbuddy::status('details', 'Scheduling next step to run at `' . $cron_time . '` (localized time: ' . pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time($cron_time)) . ') with cron tag `backupbuddy_cron` to run method `process_backup` and serial arguments `' . implode(',', $cron_args) . '`.');
     $schedule_result = backupbuddy_core::schedule_single_event($cron_time, 'process_backup', $cron_args);
     if ($schedule_result === false) {
         pb_backupbuddy::status('error', 'Unable to schedule next cron step. Verify that another plugin is not preventing / conflicting.');
     } else {
         pb_backupbuddy::status('details', 'Next step scheduled.');
         pb_backupbuddy::status('startAction', 'cronPass');
         pb_backupbuddy::status('cronParams', base64_encode(json_encode(array('time' => $cron_time, 'tag' => 'backupbuddy_cron', 'method' => 'process_backup', 'args' => $cron_args))));
     }
     update_option('_transient_doing_cron', 0);
     // Prevent cron-blocking for next item.
     // Spawn cron.
     if ($spawn_cron === true) {
         pb_backupbuddy::status('details', 'Calling spawn_cron().');
         spawn_cron(time() + 150);
         // Adds > 60 seconds to get around once per minute cron running limit.
     } else {
         pb_backupbuddy::status('details', 'Not calling spawn_cron().');
     }
     $next_step_note = '';
     if ('' != $next_step_title) {
         $next_step_note = ' (' . $next_step_title . ' expected)';
     }
     pb_backupbuddy::status('details', 'About to run next step' . $next_step_note . '. If the backup does not proceed within 15 seconds then something is interfering with the WordPress CRON system such as: server loopback issues, caching plugins, or scheduling plugins. Try disabling other plugins to see if it resolves issue.  Check the Server Information page cron section to see if the next BackupBuddy step is scheduled to run. Enable "Classic" backup mode on the "Settings" page to rule out non-cron issues. Additionally you may verify no other backup processes are trying to run at the same time by verifying there is not an existing backup process listed in the cron hogging the cron process.');
     return;
 }
开发者ID:Brandonsmith23,项目名称:prodgyr,代码行数:69,代码来源:backup.php

示例12: connect_database

 /**
  *	connect()
  *
  *	Initializes a connection to the mysql database.
  *
  *	@return		boolean		True on success; else false. Success testing is very loose.
  */
 function connect_database()
 {
     // Set up database connection.
     if (false === @mysql_connect(pb_backupbuddy::$options['db_server'], pb_backupbuddy::$options['db_user'], pb_backupbuddy::$options['db_password'])) {
         pb_backupbuddy::alert('ERROR: Unable to connect to database server and/or log in. Verify the database server name, username, and password. Details: ' . mysql_error(), true, '9006');
         return false;
     }
     $database_name = mysql_real_escape_string(pb_backupbuddy::$options['db_name']);
     pb_backupbuddy::flush();
     // Select the database.
     if (false === @mysql_select_db(pb_backupbuddy::$options['db_name'])) {
         pb_backupbuddy::status('error', 'Error: Unable to connect or authenticate to database `' . pb_backupbuddy::$options['db_name'] . '`.');
         return false;
     }
     // Set up character set. Important.
     mysql_query("SET NAMES 'utf8'");
     return true;
 }
开发者ID:jimlongo56,项目名称:bhouse,代码行数:25,代码来源:import.php

示例13: status

 /**
  *	self::status()
  *
  *	Logs data to a CSV file. Optional unique serial identifier.
  *	If a serial is passed then EVERYTHING will be logged to the specified serial file in addition to whatever (if anything) is logged to main status file.
  *	Always logs to main status file based on logging settings whether serial is passed or not.
  *
  *	@see self::get_status().
  *
  *	@param	string			$type		Valid types: error, warning, details, message
  *	@param	string			$text		Text message to log.
  *	@param	string|array	$serial		Optional. Optional unique identifier for this plugin's message. Status messages are unique per plugin so this adds an additional unique layer for retrieval.
  *										If self::$_status_serial has been set by set_status_serial() then it will override if $serial is blank.
  *	@return	null
  */
 public static function status($type, $message, $serials = '', $js_mode = false)
 {
     if (!class_exists('backupbuddy_core')) {
         require_once pb_backupbuddy::plugin_path() . '/classes/core.php';
     }
     if (self::$_status_serial != '' && $serials == '') {
         $serials = self::$_status_serial;
     }
     if (!is_array($serials)) {
         $serials = array($serials);
     }
     global $pb_backupbuddy_js_status;
     if (defined('PB_IMPORTBUDDY') || isset($pb_backupbuddy_js_status) && $pb_backupbuddy_js_status === true) {
         $status = pb_backupbuddy::$format->date(time()) . "\t" . sprintf("%01.2f", round(microtime(true) - pb_backupbuddy::$start_time, 2)) . "\t" . sprintf("%01.2f", round(memory_get_peak_usage() / 1048576, 2)) . "\t" . $type . "\t" . str_replace(chr(9), '   ', $message);
         $status = str_replace('\\', '/', $status);
         echo '<script type="text/javascript">pb_status_append("' . str_replace("\n", '\\n', str_replace('"', '&quot;', $status)) . '");</script>';
         pb_backupbuddy::flush();
     }
     if (defined('BACKUPBUDDY_WP_CLI') && true === BACKUPBUDDY_WP_CLI) {
         if (class_exists('WP_CLI')) {
             WP_CLI::line($type . ' - ' . $message);
         }
     }
     $delimiter = '|~|';
     // Make sure we have a unique log serial for all logs for security.
     if (!isset(self::$options['log_serial']) || self::$options['log_serial'] == '') {
         self::$options['log_serial'] = self::random_string(15);
         self::save();
     }
     foreach ($serials as $serial) {
         // Determine whether writing to main file.
         $write_main = false;
         if (self::$options['log_level'] == 0) {
             // No logging.
             $write_main = false;
         } elseif (self::$options['log_level'] == 1) {
             // Errors only.
             if ($type == 'error') {
                 $write_main = true;
                 self::log('[' . $serial . '] ' . $message, 'error');
             }
         } else {
             // Everything else.
             $write_main = true;
             self::log('[' . $serial . '] ' . $message, $type);
         }
         // Determine whether writing to serial file. Ignores log level.
         if ($serial != '') {
             $write_serial = true;
         } else {
             $write_serial = false;
         }
         // Return if not writing to any file.
         if ($write_main !== true && $write_serial !== true) {
             return;
         }
         // Calculate log directory.
         $log_directory = backupbuddy_core::getLogDirectory();
         // Also handles when within importbuddy.
         // Prepare directory for log files. Return if unable to do so.
         if (true === self::$_skiplog) {
             // bool true so skip.
             return;
         } elseif (false !== self::$_skiplog) {
             // something other than bool false so check directory before proceeding.
             if (true !== self::anti_directory_browsing($log_directory, $die_on_fail = false, $deny_all = false, $suppress_alert = true)) {
                 // Unable to secure directory. Fail.
                 self::$_skiplog = true;
                 return;
             } else {
                 self::$_skiplog = false;
             }
         }
         // Function for writing actual log CSV data. Used later.
         if (!function_exists('write_status_line')) {
             function write_status_line($file, $content_array, $delimiter)
             {
                 $delimiter = '|~|';
                 if (false !== ($file_handle = @fopen($file, 'a'))) {
                     // Append mode.
                     //fputcsv ( $file_handle , $content_array );
                     @fwrite($file_handle, trim(implode($delimiter, $content_array)) . PHP_EOL);
                     @fclose($file_handle);
                 } else {
                     //pb_backupbuddy::alert( 'Unable to open file handler for status file `' . $file . '`. Unable to write status log.' );
//.........这里部分代码省略.........
开发者ID:serker72,项目名称:T3S,代码行数:101,代码来源:_pluginbuddy.php

示例14: rollback

    public function rollback()
    {
        pb_backupbuddy::$ui->ajax_header();
        pb_backupbuddy::load_script('jquery');
        echo '<div id="pb_backupbuddy_working" style="width: 100px; margin-bottom: 30px;"><br><center><img src="' . pb_backupbuddy::plugin_url() . '/images/working.gif" title="Working... Please wait as this may take a moment..."></center></div>';
        ?>
		
		
		<script>
		function pb_status_append( status_string ) {
			var win = window.dialogArguments || opener || parent || top;
			win.pb_status_append( status_string );
		}
		function pb_status_undourl( undo_url ) {
			var win = window.dialogArguments || opener || parent || top;
			win.pb_status_undourl( undo_url );
		}
		
		var win = window.dialogArguments || opener || parent || top;
		win.window.scrollTo(0,0);
		</script>
		
		
		<?php 
        global $pb_backupbuddy_js_status;
        $pb_backupbuddy_js_status = true;
        pb_backupbuddy::set_status_serial('restore');
        $step = strip_tags(pb_backupbuddy::_GET('step'));
        if ('' == $step || !is_numeric($step)) {
            $step = 0;
        }
        $backupFile = strip_tags(pb_backupbuddy::_GET('archive'));
        if ('' == $backupFile) {
            pb_backupbuddy::alert('The backup file to restore from must be specified.');
            die;
        }
        $stepFile = pb_backupbuddy::plugin_path() . '/controllers/pages/rollback/_step' . $step . '.php';
        if (!file_exists($stepFile)) {
            pb_backupbuddy::alert('Error #849743. Invalid roll back step `' . htmlentities(pb_backupbuddy::_GET('step')) . '` (' . $step . ').');
            die;
        }
        require $stepFile;
        echo '<br><br><br>';
        echo '<script type="text/javascript">jQuery("#pb_backupbuddy_working").hide();</script>';
        pb_backupbuddy::$ui->ajax_footer();
        pb_backupbuddy::flush();
        die;
    }
开发者ID:serker72,项目名称:T3S,代码行数:48,代码来源:ajax.php

示例15: connect_database

 /**
  *	connect()
  *
  *	Initializes a connection to the mysql database.
  *
  *	@return		boolean		True on success; else false. Success testing is very loose.
  */
 function connect_database()
 {
     pb_backupbuddy::flush();
     global $wpdb;
     $wpdb = new wpdb(pb_backupbuddy::$options['db_user'], pb_backupbuddy::$options['db_password'], pb_backupbuddy::$options['db_name'], pb_backupbuddy::$options['db_server']);
     pb_backupbuddy::flush();
     return true;
 }
开发者ID:serker72,项目名称:T3S,代码行数:15,代码来源:import.php


注:本文中的pb_backupbuddy::flush方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。