<% Server.ScriptTimeout = 99999 Admin_header ' Response.Write ' <body oncontextmenu= "return false" "Ondragstart=" "return false" "Onselectstart=" "return false" > " '===================================================================== ' Software name: New Cloud Website Management system ' Current version: Newcloud Site Management System version 2.1 ' File name: admin_database.asp ' Update Date: 2004-11-20
'===================================================================== ' Copyright 2002-2005 newasp.net-all Rights Reserved. ' Newasp is a trademark of newasp.net '===================================================================== Dim Bkfolder, Bkdbname, FSO, FSO1 Dim Action Action = LCase (Request ("action") Select Case Action
Case "Renamedata" database renamed
If not Chkadmin ("Renamedata") Then
Server.Transfer ("showerr.asp")
Request.end
End If
Call Renamedata ()
Case "Backupdata" Backup data
If not Chkadmin ("Backupdata") Then
Server.Transfer ("showerr.asp")
Request.end
End If
If Request ("act") = "Backup" Then
If issqldatabase = 1 Then
Call Backupsqldatabase ()
Else
Call BackupDatabase ()
End If
Else
Call Backupdata ()
End If
Case "Compressdata" ' compressed data
If not Chkadmin ("Compressdata") Then
Server.Transfer ("showerr.asp")
Request.end
End If
If Request ("act") = "Compress" Then
Call Compressdatabase ()
Else
Call Compressdata ()
End If
Case "Restoredata" ' recovery data
If not Chkadmin ("Restoredata") Then
Server.Transfer ("showerr.asp")
Request.end
End If
If Request ("act") = "Restore" Then
If issqldatabase = 1 Then
Call Restoresqldatabase ()
Else
Call Restoredatabase
End If
Application.Contents.RemoveAll
Else
Call Restoredata ()
End If Case "Spacesize" ' System space occupancy If not Chkadmin ("Spacesize") Then Server.Transfer ("showerr.asp") Request.end End If Call Spacesize () Case Else ErrMsg = errmsg + <BR><li> Select the appropriate action. " Returnerror (errmsg) End Select
If Founderr = True Then
Returnerror (errmsg)
End If
Admin_footer
Saveloginfo (AdminName)
Closeconn
' ==================== system space occupancy =======================
Sub spacesize ()
On Error Resume Next
%>
Border= "0" cellspacing= "1" cellpadding= "5" height= "1" align=center width= "<table" class= "Tableborder" > <t R>
<th height=25>
Space occupancy of &nbsp;&nbsp; system
</th>
</tr>
<tr>
<TD class= "TableRow1" >
<blockquote>
<br>
Regulatory Data Occupation Space: &nbsp;<img src= "Images/bar1.gif" Width=<%=drawbar (". /database ")%> height=10>&nbsp;<%showspaceinfo (". /database ")%><br><br>
Backup data footprint: &nbsp;<img src= "Images/bar1.gif" Width=<%=drawbar ("DataBackup")%> height=10>&nbsp; <%showspaceinfo ("DataBackup")%><br><br>
Admin occupy Space: &nbsp;<img src= "Images/bar1.gif" Width=<%=drawbar ("./")%> height=10>&nbsp;<% Showspaceinfo ("./")%><br><br>
Software channel occupancy space: &nbsp;<img src= "Images/bar1.gif" Width=<%=drawbar (". /soft ")%> height=10>&nbsp;<%showspaceinfo (". /soft ")%><br><br>
Article Channel occupancy space: &nbsp;<img src= "Images/bar1.gif" Width=<%=drawbar (". /article ")%> height=10>&nbsp;<%showspaceinfo (". /article ")%><br><br>
Template pictures occupy space: &nbsp;<img src= "Images/bar1.gif" Width=<%=drawbar (". /skin ")%> height=10>&nbsp;<%showspaceinfo (". /skin ")%><br><br>
Picture files occupy space: &nbsp;<img src= "Images/bar1.gif" Width=<%=drawbar (". /images ")%> height=10>&nbsp;<%showspaceinfo (". /images ")%><br><br>
User files Occupy space: &nbsp;<img src= "Images/bar1.gif" Width=<%=drawbar (". /user ")%> height=10>&nbsp;<%showspaceinfo (". /user ")%><br><br>
Upload files occupy space: &nbsp;<img src= "Images/bar1.gif" Width=<%=drawbar (". /uploadfile ")%> height=10>&nbsp;<%showspaceinfo (". /uploadfile ")%><br><br>
Total space occupied by the system: &nbsp;<img src= "Images/bar2.gif" width=400 height=10> <%showspecialspaceinfo ("All")%>
</blockquote>
</td>
</tr>
</table>
<%
End Sub Sub Sqluserreadme ()
%>
Border= "0" cellspacing= "1" cellpadding= "5" height= "1" align=center width= "<table" class= "Tableborder" > <t R>
<th height=25>
&nbsp;&nbsp; SQL database Data processing instructions
</th>
</tr>
<tr>
<TD class= "TableRow1" >
<blockquote>
<B> A, backup database </B>
<BR><BR>
1, open SQL Enterprise Manager, in the console root directory in turn open Microsoft SQL server<br>
2, SQL Server group--> double hit Open your server--> double-click to open the database directory <BR>
3, select your database name (such as System database newasp)--> then click the Tools in the above menu--> Select Backup Database <BR>
4, Backup options Select Full Backup, the purpose of the backup to the original if there is a path and name then select the name Point Delete, then click Add, if there is no path and name is directly selected to add, and then specify the path and filename, specify the back-point of the Backup window, and then click OK
<BR><BR>
<B> II, RESTORE Database </B><BR><BR>
1, open SQL Enterprise Manager, in the console root directory in turn open Microsoft SQL server<br>
2, SQL Server group--> double hit Open your server--> point icon Bar of the new database icon, the name of the new database to pick <BR>
3, click on the new database name (such as System database newasp)--> then click the Tools in the above menu--> select Restore Database <BR>
4, in the pop-up window of the Restore option select from the device--> point Select Device--> Point add--> and then select your backup file name--> Add after the point of return, this time the device bar should appear you just select the database backup file name, The backup number defaults to 1 (if you have multiple backups of the same file, you can click on the view next to the backup number, select the latest backup point in the check box)--> then click the option button next to the general section above <BR>
5. Select the Force restore on the existing database in the window that appears, and select the option to keep the database running but not to restore other transaction logs in the recovery completion state. In the middle of the window to restore the database file to here to follow the installation of your SQL settings (you can also specify your own directory), the logical file name does not need to change, to move to the physical file name to change according to the machine condition you restored, such as your SQL database installed in D:\Program files\ Microsoft SQL Server\MSSQL\Data, then follow the changes that you have made to the directory where you restored the machine, and the last file name is best changed to your current database name (such as the original Newcloud_ Data.mdf, now the database is newasp, changed to Newasp_data.mdf), log and data files are to do in this way related changes (log file name is *_ Log.ldf end of), here's the recovery directory you can set freely, provided that the directory must exist (such as you can specify D:\sqldata\NewCloud_data.mdf or d:\sqldata\NewCloud_log.ldf), otherwise recovery will be an error <BR>
6, after the completion of the modification, click on the determination of the following recovery, there will be a progress bar, prompt recovery progress, the system will automatically prompt success after recovery, such as the middle of the prompt error, please record the relevant errors and ask about the SQL operation more familiar with the personnel, The general error is simply a directory error or file name duplication or file name error or lack of space or database is in use error, database is using the error you can try to close all about the SQL window and then reopen for recovery operations, If you also hint that the error you are using can stop the SQL service and then restart it, the other errors mentioned above can be restored after the error content is changed <BR><BR> <B> Shrinking Database </B><BR><BR> In general, the contraction of the SQL database does not greatly reduce the size of the database, its primary role is to shrink the log size, this should be done periodically to avoid the database log too large <BR> 1, set the database mode to Simple mode: Open SQL Enterprise Manager, in the console root in turn, click the Microsoft SQL Server-->sql Server group--> double hit Open your server--> double-click to open the database directory--> Select your database name (such as System database newasp)--> and then right-click to select Properties--> Select option--> in the failover mode select "Simple" and then press OK to save <BR> 2, in the current database point right, look at all tasks in the shrinking database, the general inside the default settings do not need to adjust, direct point determine <BR> 3, <font color=blue> shrink the database is complete, it is recommended to reset your database properties to standard mode, the operation method with the 1th, because the log in some unusual circumstances is often the important basis for the recovery of the database </font> <BR><BR> <B> set up daily automatic backup database </B><BR><BR>
<font Color=red> strongly recommends that a conditional user do this! </font><BR>
1, open Enterprise Manager, in the console root directory in turn open Microsoft SQL Server-->sql Server group--> double hit Open your server <BR>
2, then click the Tools in the above menu--> Select Database Maintenance Planner <BR>
3, next select the data to be automatically backed up--> next update data optimization information, here generally do not choose--> Next check data integrity, also generally do not choose <BR>
4, the next step to specify the database maintenance plan, the default is 1 weeks backup, click Change Select Daily Backup After the point of determination <BR>
5, next specify the backup disk directory, select the specified directory, such as you can create a new directory in D disk such as: D:\databak, and then choose to use this directory here, if your database is more than best choose to create subdirectories for each database, and then choose to delete the backup earlier than how many days ago, Generally set 4-7 days, this depends on your specific backup requirements, backup file extensions are generally bak with the default <BR>
6, next specify the transaction log backup plan, see your needs to make a choice--> next to generate reports, generally do not choose--> Next maintenance Plan history, preferably with the default option--> next step to complete <BR>
7, after the completion of the system is likely to prompt the SQL Server Agent service is not started, the first point to determine the completion plan, and then find the desktop rightmost status bar in the SQL Green icon, double-click Point Open, select SQL Server Agent in the service, and then click the run arrow, Start the service automatically when you start the OS <BR>
8, this time the database plan has been successfully run, he will follow the settings above you to automatically back up
<BR><BR>
Modify Schedule:<br>
1, open Enterprise Manager, in the console root directory in order to open Microsoft SQL Server-->sql Server group--> double hit Open your server--> admin--> Database Maintenance Plan--> open to see the plan you set , you can modify or delete an operation
<BR><BR>
<B> v. Transfer of data (new database or transfer server) </B><BR><BR>
Under normal circumstances, it is best to use Backup and restore operations to transfer data, in special cases, you can use the Import export method to transfer, here is the Import Export mode, import Export mode transfer data one function is to reduce (shrink) the size of the database in the case of shrinking the database. This operation by default for you have a certain understanding of the operation of the SQL, if some of the operations do not understand, you can consult the network related personnel or inquiries online information <BR>
1, the original database of all the tables, stored procedures exported to a SQL file, export time note in the option to write index script and write primary key, foreign key, default value and check Constraint script options <BR>
2. Create a new database, execute the SQL file created in the first step of the new database <BR>
3, with SQL import and export way, to the new database to import all the table content in the original database <BR>
</blockquote>
</td>
</tr>
</table>
<%
End Sub
' ==================== database renamed =========================
Sub Renamedata ()
If issqldatabase = 1 Then
Sqluserreadme ()
Exit Sub
End If
Dim Accdatapath,accdataname,saccdatapath
Accdatapath = Replace (db, "/", "\")
Saccdatapath = Split (Accdatapath, "\")
Accdataname = Saccdatapath (UBound (Saccdatapath))
%>
<table width= "border=" 0 "align=" center "cellpadding=" 2 "cellspacing=" 1 "class=" Tableborder ">
<tr><th colspan=2 height= ">&nbsp;&nbsp;" library renamed (Need FSO support, FSO related help please see Microsoft website) </th></tr>
<TD width= "30%" class= "tablerow1highlight" height=23> Please enter the database name <BR> operations you want to change before you best back up the database! </td>
<form action= "Admin_datarename.asp?action=rename" method= "POST" >
<input type=hidden name= "Olddataname" value= "<%=db%>" >
<TD width= "70%" class= "TableRow1" ><input name= "Newdataname" value= "<%=AccDataName%>" size= ">"
<input name= "B1" type= "Submit" Class=button value= "Confirm renaming" ></td></form>
</tr>
</table>
<%
End Sub ' ==================== Recovery Database ========================= Sub Restoredata ()
If issqldatabase = 1 Then
%>
Border= "0" cellspacing= "1" cellpadding= "5" height= "1" align=center width= "<table" class= "Tableborder" >
<tr>
<th height=25 >
&nbsp;&nbsp; Recover SQL data
</th>
</tr>
<form method= "POST" action= "Action=restoredata&act=restore" >
<tr>
<TD height=100 class= "TableRow1" >
&nbsp;&nbsp;
Restore SQL database name: <input type=text size=25 name=sqldataname value= "<%=SqlDatabaseName%>" ><BR>&nbsp; &nbsp;
SQL database user name: <input type=text size=25 name=sqluserid value= "<%=SqlUsername%>" >&nbsp; Please enter your SQL database username <BR>&nbsp;&nbsp;
SQL database user password: <input type=password size=25 name=sqluserpass value= "<%=SqlPassword%>" >&nbsp; Please enter your SQL database connection password <BR>&nbsp;&nbsp;
SQL database server name: <input type=text size=25 name=sqlserver value= "<%=SqlLocalName%>" >&nbsp; connection server name (locally with local , field with IP) <BR>&nbsp;&nbsp;
Backup SQL database directory: <input type=text size=25 name=backupsqldir value= "databackup" >&nbsp; Please enter the database directory you backed up <BR> &nbsp;&nbsp;
Backup SQL database name: <input type=text size=25 name=backupsqlname value= "$1.bak" >&nbsp; Please enter the database name you backed up <BR>
&nbsp;&nbsp;<input type=submit value= "RESTORE Database" class=button><br>
-----------------------------------------------------------------------------------------<br>
&nbsp;&nbsp; You can use this feature to restore your regulatory data, please make sure that your database users have the relevant permissions to restore! <br>
&nbsp;&nbsp; Note: Database may not be restored in use </font>
</td>
</tr>
</form>
</table>
<%
Else
%>
<table border= "0" cellspacing= "1" cellpadding= "5" height= "1" align=center width= "over" class= "" Tableborder "<tr" >
<th height=25 >
&nbsp;&nbsp; Restore System data (need FSO support, FSO related help please see Microsoft website)
</th>
</tr>
<form method= "POST" action= "Action=restoredata&act=restore" >
<tr>
<TD height=100 class= "TableRow1" >
&nbsp;&nbsp; Backup Database path (relative): <input type=text size=45 name=dbpath value= "Databackup\newcloud_backup.mdb" > &nbsp;&nbsp;<BR>
&nbsp;&nbsp; Target database path (relative): <input type=text size=45 name=backpath value= "<%=db%>" ><BR>& nbsp;&nbsp; fill in the database path you are currently using, if you do not want to overwrite the current file, you can name it (note that the path is correct), and then modify the conn.asp file, if the target file name and the current database name is the same, do not need to modify the conn.asp file < Br>
&nbsp;&nbsp;<input type=submit value= "RESTORE Database" class=button> <br>
-----------------------------------------------------------------------------------------<br>
&nbsp;&nbsp; in the above fill in this program's database path full name, this program's default backup database file is Databackup\newcloud_backup.mdb, please follow your backup file to modify. <br>
&nbsp;&nbsp; You can use this feature to back up your regulatory data to keep your data secure! <br>
&nbsp;&nbsp; Note: All paths are relative to the program space root directory relative path </font>
</td>
</tr>
</form>
</table>
<%
End If
End Sub
' ==================== Backup Database =========================
Sub Backupdata ()
If issqldatabase = 1 Then
%>
Border= "0" cellspacing= "1" cellpadding= "5" height= "1" align=center width= "<table" class= "Tableborder" >
<tr>
<th height=25 >
&nbsp;&nbsp; Backup SQL data
</th>
</tr>
<form method= "POST" action= "Action=backupdata&act=backup" >
<tr>
<TD height=100 class= "TableRow1" >
&nbsp;&nbsp;
Current SQL database name: <input type=text size=25 name=sqldataname value= "<%=SqlDatabaseName%>" ><BR>&nbsp; &nbsp;
SQL database user name: <input type=text size=25 name=sqluserid value= "<%=SqlUsername%>" >&nbsp; Please enter your SQL database username <BR>&nbsp;&nbsp;
SQL database user password: <input type=password size=25 name=sqluserpass value= "<%=SqlPassword%>" >&nbsp; Please enter your SQL database connection password <BR>&nbsp;&nbsp;
SQL database server name: <input type=text size=25 name=sqlserver value= "<%=SqlLocalName%>" >&nbsp; connection server name (locally with local , field with IP) <BR>&nbsp;&nbsp;
Backup SQL database directory: <input type=text size=25 name=backupsqldir value= "databackup" >&nbsp; if directory does not exist, the program will automatically create <BR> &nbsp;&nbsp;
Backup SQL database name: <input type=text size=25 name=backupsqlname value= "$1.bak" >&nbsp; if you use the default backup name, The system will automatically create a backup name by date time <BR>
&nbsp;&nbsp;<input type=submit value= "Backup Database" class=button><br>
-----------------------------------------------------------------------------------------<br>
&nbsp;&nbsp; You can use this feature to back up your regulatory data to keep your data secure! <br>
&nbsp;&nbsp; Note: All paths are relative to program space management directory relative path </font>
</td>
</tr>
</form>
</table>
<%
Else
%>
Border= "0" cellspacing= "1" cellpadding= "5" height= "1" align=center width= "<table" class= "Tableborder" >
<tr>
<th height=25 >
&nbsp;&nbsp; Backup system data (need FSO support, FSO related help please see Microsoft website)
</th>
</tr>
<form method= "POST" action= "Action=backupdata&act=backup" >
<tr>
<TD height=100 class= "TableRow1" >
&nbsp;&nbsp;
Current database path (relative path): <input type=text size=45 name=dbpath size=45 value= "<%=db%>" ><BR>&nbsp;& nbsp
Backup database directory (relative path): <input type=text size=20 name=bkfolder size=45 value=databackup>&nbsp; If directory does not exist, the program will automatically create <BR >&nbsp;&nbsp;
Backup database name (fill in name): <input type=text size=20 name=bkdbname size=45 value=newcloud_backup.mdb>&nbsp; If the backup directory has the file, Will overwrite, if not, will automatically create <BR>
&nbsp;&nbsp;<input type=submit value= "Backup Database" class=button><br>
-----------------------------------------------------------------------------------------<br>
&nbsp;&nbsp; fill in the above database path full name of this program, the default database file for this program is <%=db%>,<B> please be sure you cannot name the backup database with the default name </B><br>
&nbsp;&nbsp; You can use this feature to back up your regulatory data to keep your data secure! <br>
&nbsp;&nbsp; Note: All paths are relative to program space management directory relative path </font>
</td>
</tr>
</form>
</table>
<%
End If
End Sub Sub BackupDatabase ()
DBPath = Request. Form ("DBPath")
If InStr (DBPath, ":") = 0 Then
DBPath = Server.MapPath (DBPath)
Else
DBPath = DBPath
End If
Bkfolder = Request. Form ("Bkfolder")
Bkdbname = Request. Form ("Bkdbname")
Set Fso = server. CreateObject ("Scripting.FileSystemObject")
If FSO. FileExists (DBPath) Then
If Checkdir (bkfolder) = True Then
Fso. CopyFile dbpath, bkfolder& "\" & Bkdbname
Else
Makenewsdir Bkfolder
Fso. CopyFile dbpath, bkfolder& "\" & Bkdbname
End If
SUCCEED ("Backup database is successful, your backup database path is" &bkfolder& \ "& Bkdbname)
Else
Founderr = True
ErrMsg = "The file you need to back up is not found. "
Exit Sub
End If
End Sub
Sub Restoredatabase ()
Dim Backpath,dbpath
DBPath = Request. Form ("DBPath")
Backpath = Request. Form ("Backpath")
If DBPath = "" Then
Founderr = True
ErrMsg = "Please enter the full name of the database you want to restore"
Exit Sub
End If
If InStr (DBPath, ":") = 0 Then
DBPath = Server.MapPath (DBPath)
Else
DBPath = DBPath
End If
If InStr (Backpath, ":") = 0 Then
Backpath = Server.MapPath (Backpath)
Else
Backpath = Backpath
End If
Set Fso = server. CreateObject ("Scripting.FileSystemObject")
If FSO. FileExists (DBPath) Then
Fso. CopyFile DBPath, Backpath
Succeed ("Recover data successfully!") ")
Else
Founderr = True
ErrMsg = "Backup directory does not have your backup file!" "
Exit Sub
End If
End Sub
'------------------Check if a directory exists-------------------
Function Checkdir (FolderPath)
FolderPath = Server.MapPath (".") & "\" &folderpath
Set Fso1 = CreateObject ("Scripting.FileSystemObject")
If Fso1. FolderExists (FolderPath) Then
' Existence
Checkdir = True
Else
' does not exist
Checkdir = False
End If
Set Fso1 = Nothing
End Function
'-------------generate a directory based on the specified name-----------------------
Function Makenewsdir (foldername)
Dim F
Set Fso1 = CreateObject ("Scripting.FileSystemObject")
Set f = fso1. CreateFolder (FolderName)
Makenewsdir = True
Set Fso1 = Nothing
End Function
' ==================== Compressed Database =========================
Sub Compressdata () If issqldatabase = 1 Then
Sqluserreadme ()
Exit Sub
End If
%>
Border= "0" cellspacing= "1" cellpadding= "5" height= "1" align=center width= "<table" class= "Tableborder" >
<tr>
<th height=25 >
&nbsp;&nbsp; compressed database (need FSO support, FSO related help please see Microsoft website)
</th>
<form action= "? action=compressdata&act=compress" method= "POST" >
<tr>
<TD class= "TableRow1" height=25><b> note:</b><br> the relative path where the database is entered and enter the database name (the database in use cannot be compressed. Please select BACKUP database for compression operation) </td>
</tr>
<tr>
<TD class= "TableRow1" > Compressed database: <input type= "text" name= "DBPath" size=45 value=<%=db%>>&nbsp;
<input type= "Submit" value= "start Compression" class=button></td>
</tr>
<tr>
<TD class= "TableRow1" ><input type= "checkbox" Name= "boolIs97" value= "True" > If you use an Access 97 database, select
(The default is Access 2000 database) <br><br></td>
</tr>
<form>
</table>
<%
End Sub Sub Compressdatabase () Dim DBPath, BOOLIS97 DBPath = Request ("DBPath") BOOLIS97 = Request ("BOOLIS97") If dbpath <> "" Then If InStr (DBPath, ":") = 0 Then DBPath = Server.MapPath (DBPath) Else DBPath = DBPath End If Response.Write (Compactdb (DBPath, BOOLIS97)) Else Founderr = True ErrMsg = "Please enter the database path to compress!" " Exit Sub End If End Sub ' ===================== compression parameter ========================= Function Compactdb (DBPath, BOOLIS97) Dim FSO, Engine, Strdbpath, jet_3x Strdbpath = Left (DBPath, InStrRev (DBPath, "\")) Set fso = CreateObject ("Scripting.FileSystemObject") If FSO. FileExists (DBPath) Then Fso. CopyFile DBPath, Strdbpath & "Temp.mdb" Set Engine = CreateObject ("JRO. JetEngine ") if boolIs97 = "True" Then engine.compactdatabase "provider= Microsoft.jet.oledb.4.0;data source= "& Strdbpath &" Temp.mdb ", _ " provider= Microsoft.jet.oledb.4.0;data source= "& Strdbpath &" Temp1.mdb; "_ &" Jet OLE DB : Engine type= "& jet_3x else engine.compactdatabase" provider= Microsoft.jet.oledb.4.0;data source= "& Strdbpath &" Temp.mdb ", _ " provider= Microsoft.jet.oledb.4.0;data source= "& Strdbpath &" Temp1.mdb " end If fso. CopyFile Strdbpath & "Temp1.mdb", DBPath fso. DeleteFile (Strdbpath & "Temp.mdb") fso. DeleteFile (Strdbpath & "Temp1.mdb") set fso = Nothing set Engine = Nothing succeed ("Your Database," & DBPath & ", has been compressed successfully!") else returnerror ("The database name or path is incorrect.) Please try again! ") end If End Function ' ===================== system space parameter ========================= Sub showspaceinfo (drvpath) Dim FSO, D, Size, showsize set FSO = server. CreateObject ("Scripting.FileSystemObject") drvpath = Server.MapPath (drvpath) set d = fso. GetFolder (drvpath) size = d.size showsize = Size & Byte if size>1024 Then size = (size/1024) showsize = FormatNumber (Size, 2) & " KB ' end If if size>1024 Then size = (size/1024) showsize = Format Number (Size, 2) & " MB ' end If if size>1024 Then size = (size/1024) showsize = Format Number (Size, 2) & " GB " end If response. Write "<font face=verdana>" & showsize & "</font>" End Sub Sub Showspecialspaceinfo (method) Dim FSO, D, FC, F1, Size, Showsize, Drvpath Set FSO = server. CreateObject ("Scripting.FileSystemObject") Drvpath = Server.MapPath (".. /") ' Drvpath = Left (Drvpath, (InStrRev (Drvpath, "\")-1) Set d = fso. GetFolder (Drvpath) If method = ' All ' Then Size = D.size ElseIf method = "program" Then Set FC = D.files For each F1 in FC Size = size + F1. Size Next End If Showsize = Size & Byte " If size>1024 Then Size = (size/1024) Showsize = FormatNumber (Size, 2) & " KB " End If If size>1024 Then Size = (size/1024) Showsize = FormatNumber (Size, 2) & " MB " End If If size>1024 Then Size = (size/1024) Showsize = FormatNumber (Size, 2) & " GB " End If Response. Write "<font face=verdana>" & showsize & "</font>" End Sub Function drawbar (Drvpath) Dim FSO, Drvpathroot, D, Size, TotalSize, barsize Set FSO = server. CreateObject ("Scripting.FileSystemObject") Drvpathroot = Server.MapPath (".. /pic ") Drvpathroot = Left (Drvpathroot, (InStrRev (drvpathroot, "\")-1) Set d = fso. GetFolder (Drvpathroot) TotalSize = D.size Drvpath = Server.MapPath (Drvpath) Set d = fso. GetFolder (Drvpath) Size = D.size Barsize = CDBL ((size/totalsize) * 400) drawbar = Barsize End Function Function Drawspecialbar () Dim FSO, Drvpathroot, D, FC, F1, Size, TotalSize, barsize Set FSO = server. CreateObject ("Scripting.FileSystemObject") Drvpathroot = Server.MapPath (".. /pic ") Drvpathroot = Left (Drvpathroot, (InStrRev (drvpathroot, "\")-1) Set d = fso. GetFolder (Drvpathroot) TotalSize = D.size Set FC = D.files For each F1 in FC Size = size + F1. Size Next Barsize = CDBL ((size/totalsize) * 400) Drawspecialbar = Barsize End Function Sub Checksql ()
If Trim (Request.Form ("Sqldataname")) = "" Then
Founderr = True
ErrMsg = errmsg & <li> Please enter the SQL database name! </li> "
End If
If Trim (Request.Form ("Sqluserpass")) = "" Then
Founderr = True
ErrMsg = errmsg & <li> Please enter the SQL database user password! </li> "
End If
If Trim (Request.Form ("SQLUserID")) = "" Then
Founderr = True
ErrMsg = errmsg & <li> Please enter the SQL database user name! </li> "
End If
If Trim (Request.Form ("SQL Server") = "" Then
Founderr = True
ErrMsg = errmsg & <li> Please enter the SQL database connection name (locally with local, field IP)! </li> "
End If
If Trim (Request.Form ("Backupsqlname")) = "" Then
Founderr = True
ErrMsg = errmsg & <li> Please enter the SQL database backup name! </li> "
End If
If Trim (Request.Form ("Backupsqldir")) = "" Then
Founderr = True
ErrMsg = errmsg & <li> Please enter the SQL database backup directory! </li> "
End If
End Sub
' ==================== Backup SQL database =========================
Sub Backupsqldatabase ()
On Error Resume Next
Dim Sqldataname, Sqluserpass, SQLUserID, SQL Server, Sqllogintimeout
Dim srv, bak, Backupfilepath, Backupsqldir, Backupsqlname,backupfilename
Sqldataname = Trim (Request.Form ("Sqldataname"))
Sqluserpass = Trim (Request.Form ("Sqluserpass"))
SQLUserID = Trim (Request.Form ("SQLUserID"))
SQL Server = Trim (Request.Form ("SQL Server"))
Backupsqldir = Trim (Request.Form ("Backupsqldir"))
Backupsqlname = Trim (Request.Form ("Backupsqlname"))
Sqllogintimeout = 20 ' login timeout
Checksql
If Founderr = True Then Exit Sub
If Checkdir (backupsqldir) = False Then
Makenewsdir Backupsqldir
End If
BackupFileName = Sqldataname & "_" & Replace (FormatDateTime (now,2), "-", "") & "_" & Replace (Formatdatetim E (now,3), ":", "")
Backupfilepath = backupsqldir & "\" & Backupsqlname
Backupfilepath = Replace (Backupfilepath, "$", BackupFileName)
Set srv = Server.CreateObject ("SQLDMO.") SQL Server ")
Srv. LoginTimeout = Sqllogintimeout
Srv. Connect SQL Server, SQLUserID, Sqluserpass
Set bak = Server.CreateObject ("SQLDMO.") Backup ")
Bak. Database = Sqldataname
' Bak. Devices = Files
Bak. Files = Backupfilepath
Bak. SQLBackup SRV
If err.number>0 Then
Response.Write Err.Number & "<font color=red><br>"
Response.Write Err.Description & "</font>"
End If
Set srv = Nothing
Set bak = Nothing
Succeed ("<li>sql database backup succeeded!") </li> ")
End Sub
' ==================== Restore SQL database =========================
Sub Restoresqldatabase ()
On Error Resume Next
Dim Sqldataname, Sqluserpass, SQLUserID, SQL Server, Sqllogintimeout
Dim srv, rest, Backupfilepath, Backupsqldir, Backupsqlname, FSO
Sqldataname = Trim (Request.Form ("Sqldataname"))
Sqluserpass = Trim (Request.Form ("Sqluserpass"))
SQLUserID = Trim (Request.Form ("SQLUserID"))
SQL Server = Trim (Request.Form ("SQL Server"))
Backupsqldir = Trim (Request.Form ("Backupsqldir"))
Backupsqlname = Trim (Request.Form ("Backupsqlname"))
Sqllogintimeout = 20 ' login timeout
Checksql
If Founderr = True Then Exit Sub
Backupfilepath = Backupsqldir & "/" & Backupsqlname
Backupfilepath = Replace (Backupfilepath, "$", Sqldataname)
Backupfilepath = Server.MapPath (Backupfilepath)
Set FSO = Server.CreateObject ("Scripting.FileSystemObject")
If FSO. FileExists (Backupfilepath) Then
Set srv = Server.CreateObject ("SQLDMO.") SQL Server ")
Srv. LoginTimeout = Sqllogintimeout
Srv. Connect SQL Server, SQLUserID, Sqluserpass
Set rest = Server.CreateObject ("SQLDMO.") Restore ")
Rest. Action = 0
Rest. Database = Sqldataname
' Rest. Devices = Files
Rest. Files = Backupfilepath
Rest. ReplaceDatabase = True
Rest. SQLRestore SRV
If err.number>0 Then
ErrMsg = errmsg & <li> An error occurred while backing up the database! </li> "
ErrMsg = errmsg & <li> error code: "
ErrMsg = errmsg & Err.Number & "</li><li><font color=red>"
' Response.Write err.number& ' <font color=red><br> '
ErrMsg = errmsg & err.description& "</font></li>"
Founderr = True
Exit Sub
End If
Set srv = Nothing
Set rest = Nothing
Succeed ("<li>sql database restored successfully!") </li> ")
Else
Founderr = True
ErrMsg = "Backup directory does not have your backup file!" "
Exit Sub
End If
Set FSO = Nothing
End Sub
%> |