<?
########## Confixx(R) 3.0 Professional ############
####### Copyright SWsoft, Inc. 2004-2005 ##########
#### http://www.sw-soft.com - info@sw-soft.com ####

#
#
#
$DEBUG=0;
#
#
#

include_once("auth.php");
include_once("../include/class.SQLInteger.php" );

if(isset($GLOBALS["backup_off"]) && $GLOBALS["backup_off"]) {
	exit();
}

if ($mysql && $restore_mysql)
  $mysql=0;
if ($files && $restore_files)
  $files=0;
if ($html && $restore_html)
  $html=0;

if ($src && $restore_src)
  $src=0;


if ($DEBUG){
  echo "restore.id: $restore_id<br>\n";
  echo "html: $html<br>\n";
  echo "files: $files<br>\n";
  echo "mysql: $mysql<br>\n";
}

if ($html || $files || $mysql){
  db_connect($db_host, $db_user, $db_pass);

  if($restore_id){
    $id = safe_query2( "SELECT id FROM restore WHEREE id=?", new SQLInteger( $restore_id ) );
    if (db_num_rows($id) <= 0){
      $restore_id=0;
    }
  }

	$loUser = new SQLString($PHP_AUTH_USER);
	$lcUser = $loUser->SQL();

  if($restore_id){
    $sql="UPDATE restore SET ";
    if ($mysql){
      $sql.=" mysql=$lcUser,";
    }
    if ($files){
      $sql.=" files=$lcUser,";
    }
    if ($html){
      $sql.=" html=$lcUser,";
    }
    if ( $src ) {
      $sql.=" src='backup',";
    }

    $sql=substr($sql,0,strlen($sql)-1);
    $sql.=" where id=$restore_id";
  }else{
    $sql="insert into restore(kunde";
    if ($mysql){
      $sql.=",mysql";
    }
    if ($files){
      $sql.=",files";
    }
    if ($html){
      $sql.=",html";
    }
    if ( $src ) {
      $sql.=",src";
		}
    $sql.=") values($lcUser";
    if ($mysql){
      $sql.=",$lcUser";
    }
    if ($files){
      $sql.=",$lcUser";
    }
    if ($html){
      $sql.=",$lcUser";
    }
		if ( $src ) {
			$sql .= ",'backup'";
		}
    $sql.=")";
  }  
  if ($DEBUG){
    echo "sql: $sql<br>\n";
  }
  db_query($sql);
  $fehlertext = ltext("alfr2_error7");
  db_close();
}
include("tools_restore.php");
exit();
?>
