/**
 * Makes Copy of a sitemap-tree and the corresponding sitepages...
 *
 * @param integer ID of the Menu to copy
 * @param integer ID of the Parent Menu where you want to copy the menu to.
 */
function copyTree($menuSource, $menuDestination)
{
    $childs = createDBCArray("sitemap", "MENU_ID", "PARENT_ID={$menuSource}");
    $dest = copySitemap($menuSource, $menuDestination);
    for ($i = 0; $i < count($childs); $i++) {
        copyTree($childs[$i], $dest);
    }
}
$target_dir = DOC_ROOT . '/backup/' . date('Ymd');
$full_backup = 0;
if (!is_dir($target_dir)) {
    mkdir($target_dir, 0777);
    $full_backup = 1;
}
if ($full_backup) {
    echo "Backing up files...";
    if (substr(php_uname(), 0, 7) == "Windows") {
        exec(SERVER_ROOT . "/server/mysql/bin/mysqldump --user=root --no-create-db --add-drop-table --databases " . DB_NAME . ">" . $target_dir . "/" . DB_NAME . ".sql");
    } else {
        exec("/usr/bin/mysqldump --user="******" --password="******" --no-create-db --add-drop-table --databases " . DB_NAME . ">" . $target_dir . "/" . DB_NAME . ".sql");
    }
    copyTree('./cms', $target_dir . '/cms', 1);
    copyTree('./texts', $target_dir . '/texts', 1);
    copyTree('./sounds', $target_dir . '/sounds', 1);
    echo "OK\n";
}
umask($old_mask);
// CHECK/REPAIR/OPTIMIZE TABLES
$tables = SQLSelect("SHOW TABLES FROM `" . DB_NAME . "`");
$total = count($tables);
for ($i = 0; $i < $total; $i++) {
    $table = $tables[$i]['Tables_in_' . DB_NAME];
    echo 'Checking table [' . $table . '] ...';
    //mysql_query("CHECK TABLE ".$table."");
    if ($result = mysql_query("CHECK TABLE " . $table . ";")) {
        echo "OK\n";
    } else {
        echo " broken ... repair ...";
        SQLExec("REPAIR TABLE " . $table . ";");
 function copyTree($source, $destination, $over=0) {

  $res=1;

  if (!Is_Dir($source)) {
   return 0; // incorrect source path
  }

  if (!Is_Dir($destination)) {
   if (!mkdir($destination, 0777)) {
    return 0; // cannot create destination path
   }
  }


 if ($dir = @opendir($source)) { 
  while (($file = readdir($dir)) !== false) { 
    if (Is_Dir($source."/".$file) && ($file!='.') && ($file!='..')) {
     $res=copyTree($source."/".$file, $destination."/".$file, $over);
    } elseif (Is_File($source."/".$file) && (!file_exists($destination."/".$file) || $over)) {
     $res=copy($source."/".$file, $destination."/".$file);
    }
  }   
  closedir($dir); 
 }
 return $res;
 }
Example #4
0
 
 if ($source=="0") {
 	$sourceMenu = "0";
 } else {
 	$sourceMenu = getDBCell("sitepage", "MENU_ID", "SPID = $source");
 }
 
 
 $page= new page ("Rollout");

 
 $go = "CREATE";
 $form = new form($lang->get("M_Rollout"), "");

 @ini_set("max_execution_time", $c_siteCaching_timeout);
 copyTree($sourceMenu, $destMenu);
 $form->buttonbar->add('link', $lang->get('new_rollout'), 'button', "document.location.href='" .$c["docroot"]. "modules/rollout/rollout.php?sid=".$sid."';");
// $form->add(new Linklabel("lbl", $lang->get("new_rollout", "Start another rollout"), "modules/rollout/rollout.php?sid=$sid", "_self", "informationheader", 2));
 if ($errors == "") {
   $form->addToTopText($lang->get('rolloutsuccess', "The copy was successful!"));
   $form->topstyle = 'headersuccess'; 	
 } else {
   $form->addToTopText($lang->get('rollouterror', "There was an error while rolling out. Please pass the following string to your Administrator!").'<br>'.$errors);
   $form->topstyle = 'headererror'; 	 	
 }
  
 
  $page->add($form);
  $page->draw();

 echo $errors;