We are currently working on our servers, so there may be outages on the domains.Zurzeit wird an unseren Servern gearbeitet, deshalb kann es zu Ausfällen bei den Domains kommen.
<?php// Code by Lutsen Stellingwerff (www.biepenlu.nl)// Copy preview site to live site// Do this bij copying the database tables and the media and pages folder from the preview to the live site.// The tables of the live site need to have a prefix,// and the tables of the preview site mus NOT have a prefix.// Start configurationdefine('DB_HOST', 'localhost');define('DB_NAME', '');define('DB_USERNAME', '');define('DB_PASSWORD', '');define('PREFIX_LIVE', 'live_');define('BASE_PATH', 'path/to/your/site');define('BASE_URL', 'http://www.yoursite.nl');define('SOURCE_PATH', '/preview');define('DEST_PATH', '/live');// End configurationif ($_POST['copysite']) {// Connect to the mysql database.$conn = mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD) or die(mysql_error());mysql_select_db(DB_NAME, $conn) or die(mysql_error());// Get existing tables$q = 'SHOW TABLES';$result = mysql_query($q,$conn);if (!$result) die("Could not read tables.<br />\n".mysql_error()."<br />\n");// Copy tables without PREFIX_LIVE to tables with PREFIX_LIVEwhile($dbarray = mysql_fetch_array($result)){ if(substr($dbarray[0], 0, strlen(PREFIX_LIVE)) != PREFIX_LIVE) { $q = 'DROP TABLE IF EXISTS '.PREFIX_LIVE.$dbarray[0]; if (!mysql_query($q,$conn)) die("Could not drop table.<br />\n".mysql_error()."<br />\n"); $q = 'CREATE TABLE '.PREFIX_LIVE.$dbarray[0].' LIKE '.$dbarray[0]; if (!mysql_query($q,$conn)) die("Could not create table.<br />\n".mysql_error()."<br />\n"); $q = 'INSERT INTO '.PREFIX_LIVE.$dbarray[0].' SELECT * FROM '.$dbarray[0]; if (!mysql_query($q,$conn)) die("Could not copy table.<br />\n".mysql_error()."<br />\n"); echo "Copied table ".$dbarray[0]."<br />\n"; }}function removeDir($path) { // Add trailing slash to $path if one is not there if (substr($path, -1, 1) != "/") { $path .= "/"; } $normal_files = glob($path . "*"); $hidden_files = glob($path . "\.?*"); $all_files = array_merge($normal_files, $hidden_files); foreach ($all_files as $file) { # Skip pseudo links to current and parent dirs (./ and ../). if (preg_match("/(\.|\.\.)$/", $file)) { continue; } if (is_file($file) === TRUE) { // Remove each file in this Directory @unlink($file); } else if (is_dir($file) === TRUE) { // If this Directory contains a Subdirectory, run this Function on it removeDir($file); } } // Remove Directory once Files have been removed (If Exists) if (is_dir($path) === TRUE) { @rmdir($path); }}// Function from SBoisvert at Don'tSpamMe dot Bryxal dot ca (http://nl3.php.net/manual/en/function.copy.php#68383)// copy a directory and all subdirectories and files (recursive)// void dircpy( str 'source directory', str 'destination directory' [, bool 'overwrite existing files'] )function dircpy($basePath, $source, $dest, $overwrite = false){ if(is_dir($basePath . $dest)) { removeDir($basePath . $dest); // remove existing directory } if(!is_dir($basePath . $dest)) { mkdir($basePath . $dest); // Make sure new folder exists } if($handle = opendir($basePath . $source)) { // if the folder exploration is sucsessful, continue while(false !== ($file = readdir($handle))) { // as long as storing the next file to $file is successful, continue if($file != '.' && $file != '..') { $path = $source . '/' . $file; if(is_file($basePath . $path)) { if(!is_file($basePath . $dest . '/' . $file) || $overwrite) if(!@copy($basePath . $path, $basePath . $dest . '/' . $file)){ echo 'File ('.$path.') could not be copied, likely a permissions problem.'; } } elseif(is_dir($basePath . $path)){ if(!is_dir($basePath . $dest . '/' . $file)) mkdir($basePath . $dest . '/' . $file); // make subdirectory before subdirectory is copied dircpy($basePath, $path, $dest . '/' . $file, $overwrite); //recurse! } } } closedir($handle); }}echo "<br />\n";// Copy media and pages directory$dir = "/media";dircpy(BASE_PATH, SOURCE_PATH.$dir, DEST_PATH.$dir, true);echo "Copied folder ".$dir.".<br />\n";$dir = "/pages";dircpy(BASE_PATH, SOURCE_PATH.$dir, DEST_PATH.$dir, true);echo "Copied folder ".$dir.".<br />\n";echo "<br />\n";echo '<a href="'.BASE_URL.SOURCE_PATH.'">'.BASE_URL.SOURCE_PATH.'</a><br />has been copied to<br /><a href="'.BASE_URL.DEST_PATH.'">'.BASE_URL.DEST_PATH.'</a>';} else {// HTML form?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head> <title>Copy PREVIEW -> LIVE</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript"> <!-- function doConfirm(message) { var name = confirm(message); // If OK is pressed the action is executed if (name == true){ return true; } else { return false; } } --> </script></head><body><div id="page"> <p> To copy<br /> <a href="<?php echo BASE_URL.SOURCE_PATH; ?>"><?php echo BASE_URL.SOURCE_PATH; ?></a><br /> to<br /> <a href="<?php echo BASE_URL.DEST_PATH; ?>"><?php echo BASE_URL.DEST_PATH; ?></a>,<br /> press the "copy" button. </p> <form name="create" action="" method="post" onsubmit="javascript:return doConfirm('Are you sure?');"> <input type="submit" name="copysite" value="copy" /> </form></div></body></html><?php}?>
This is some code I wrote to copy the databse tables and the media- and pages folders from one WB installation to another.
<?phpfunction opff_correctPath(&$content, $page_id, $section_id, $module, $wb) { // add filter hereif (strpos(WB_URL,'PATH_TO_STAGING_VIEW')==false) {$content=str_replace('/PATH_TO_STAGING_VIEW','',$content); } return(TRUE);}?>