"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
"; echo "Maintenance > Backup & Restore > Configuration"; echo ""; $helpId="5.1.6"; showHelp($helpId); echo "
"; echo "
"; echo "    "; //echo ""; //echo "From file"; //echo ""; echo "
"; echo ""; echo " "; echo "
"; adjust_title_tail(); adjust_content_head(); $ftpinfo=getMSSFtpAccount(); $selSql = "SELECT ip FROM sysInfo where sysTypeNo=388 order by updateTime desc "; $selRes = @mysqli_query($pubConn,$selSql); $num=mysqli_num_rows($selRes); $selRow = @mysqli_fetch_array($selRes); $mss_ip=$selRow[ip]; if($backup_file_flag == 1) { echo "\n"; if($num == 0) { echo "Can not get IP of MSS
"; } else { //oid 1.3.6.1.4.1.1373.2.3.3.99.2.1.1, value=6 $sql="replace into OBJ_388.param_99(subSysNo,paramType,level_1,level_2,level_3,instanceNo,sortNo,valueType,operType,length,initValue)values(99,0,2,1,1,0,0,4,0,1,'06') "; mysqli_query($pubConn,$sql); $commIdStr=oidSysCommSend("388_99_99",3,"2.1.1",-1,0); //checkState($commIdStr,"./mss_backup_restore.php"); flush(); for($t=0;$t<4;$t++) { flush(); echo ""; ob_flush(); flush(); sleep(1); } /* close ftp $conn_id=ftp_connect($mss_ip); if($conn_id == FALSE) { echo "FTP:connect to $mss_ip failed.
"; exit(); } */ $connection=sftp_connect($mss_ip); if(!$connection) { echo "SFTP:connect to $mss_ip failed.
"; exit(); } /* close ftp if(FALSE == ftp_login($conn_id,$ftpinfo[UserName],$ftpinfo[Password])) { echo "FTP:login to $mss_ip failed.
"; exit(); } */ $key=sftp_login($connection,$ftpinfo[UserName],$ftpinfo[Password]); if(!$key) { echo "SFTP:login to $mss_ip failed.
"; exit(); } $local_file="/usr/local/apache/htdocs/ftpFile/mssConf".date("YmdHis").".tar"; $remote_file="/usr/local/subsManage/conf.bk.tar"; /* close ftp if(FALSE == ftp_get($conn_id,$local_file,$remote_file,FTP_BINARY)) { echo "FTP:Get file $remote_file failed.
"; exit(); } ftp_close($conn_id); */ //if(!sftp_get($key,$local_file,$remote_file,SFTP_ASCII)) if(!sftp_get($connection,$local_file,$remote_file,SFTP_ASCII)) { echo "SFTP:Get file $remote_file failed.
"; exit(); } insertLog("Backup mss configuration file conf.bk.tar"); } } else if($restore_file_flag == 1) { echo "\n"; if($num == 0) { echo "Can not get IP of MSS
"; } else { $original_file="/usr/local/apache/htdocs/ftpFile/$backup_filename"; $ftp_file="/usr/local/apache/htdocs/ftpFile/conf.bk.tar"; system("cp -f $original_file $ftp_file"); system("chmod 777 $ftp_file"); /* close ftp $conn_id=ftp_connect($mss_ip); if($conn_id == FALSE) { echo "FTP:connect to $mss_ip failed.
"; exit(); } */ $connection=sftp_connect($mss_ip); if(!$connection) { echo "SFTP:connect to $mss_ip failed.
"; exit(); } /* close ftp if(FALSE == ftp_login($conn_id,$ftpinfo[UserName],$ftpinfo[Password])) { echo "FTP:login to $mss_ip failed.
"; exit(); } */ $key=sftp_login($connection,$ftpinfo[UserName],$ftpinfo[Password]); if(!$key) { echo "SFTP:login to $mss_ip failed.
"; exit(); } $local_file=$ftp_file; $remote_file="/usr/local/subsManage/conf.bk.tar"; /* close ftp if(FALSE == ftp_put($conn_id,$remote_file,$local_file,FTP_BINARY)) { echo "FTP:Put file $original_file failed.
"; exit(); } ftp_close($conn_id); */ if(!sftp_put($key,$remote_file,$local_file,SFTP_ASCII)) { echo "FTP:Put file $original_file failed.
"; exit(); } unlink($ftp_file); //oid 1.3.6.1.4.1.1373.2.3.3.99.2.1.1, value=7 $sql="replace into OBJ_388.param_99(subSysNo,paramType,level_1,level_2,level_3,instanceNo,sortNo,valueType,operType,length,initValue)values(99,0,2,1,1,0,0,4,0,1,'07') "; mysqli_query($pubConn,$sql); $commIdStr=oidSysCommSend("388_99_99",3,"2.1.1",-1,0); //checkState($commIdStr,"./mss_backup_restore.php"); insertLog("Restore mss configuration file from $local_file"); } } else if($download_file_flag == 1) { header("Content-type: application/csv"); header("Content-Disposition: attachment; filename=\"{$backup_filename}\""); //use for download csv in https header('Expires: 0'); header('Pragma: public'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Cache-Control: public'); readfile("/usr/local/apache/htdocs/ftpFile/{$backup_filename}"); } //Get the backup file list $dir="/usr/local/apache/htdocs/ftpFile/"; $handle=opendir($dir); if($handle == FALSE) { echo "Can not open dir $dir
"; exit(); } $filecount=0; while (($file = readdir($handle)) !== false) { if(strstr($file,"mssConf")) { $fileList[FullName][$filecount]=$dir.$file; $fileList[FileName][$filecount]=$file; $fileList[FileSize][$filecount]=filesize($dir.$file); $fileList[FileMTime][$filecount]=date("Y-m-d H:i:s",filemtime($dir.$file)); $filecount++; } } if($filecount > 0) arsort($fileList[FileMTime]); if(0) { echo "
";
print_r($fileList);
echo "
"; } closedir($handle); echo "

"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
MSS Configuration Backup FileFile SizeBackup TimeDownloadUpload
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; if($filecount > 0) { $i=0; foreach($fileList[FileMTime] as $key => $value) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; $i++; } } echo "
    
    
"; if($i == $filecount - 1) echo ""; else echo ""; echo ""; echo "{$fileList[FileName][$key]} "; echo ""; echo "{$fileList[FileSize][$key]} {$fileList[FileMTime][$key]} DownloadUpload
"; adjust_content_tail(); ?>