Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 9.39 KB | None | 0 0
  1.  
  2. <%
  3. Server.ScriptTimeOut = 25000
  4. Response.Charset="windows-1254"
  5.  
  6. Const AppCharset = "ISO-8859-9"
  7. Const AppWinCharset = "Windows-1254"
  8. Const AppLanguage = "tr"
  9. Const AppName = "Foxxly MySQL Backup"
  10. Const AppTitle = "Foxxly MySQL Backup"
  11.  
  12. strGun = Day(Date())
  13. strAy = Month(Date())
  14. strYil = Year(Date())
  15. strSaat = Hour(Now())
  16. strDakika = Minute(Now())
  17.  
  18. strBackupFolder = "C:\Inetpub\vhosts\3gpindir.com\httpdocs\bekap\"
  19. strBackupFileName = mysqlvt & "_" & strGun & "." & strAy & "." & strYil & "_" & strSaat & "." & strDakika & "-yideh.fox"
  20.  
  21. set bekapsize=sur.execute("select * from site where id='1'")
  22. koigbg=bekapsize("sonyedek")
  23. Dim fs,f
  24. Set fs=Server.CreateObject("Scripting.FileSystemObject")
  25. Set f=fs.GetFile("C:\Inetpub\vhosts\3gpindir.com\httpdocs\bekap\"&koigbg&"")
  26. kalanzaman=cint((f.Size / 1048576)*9 + 15)
  27. set f=nothing
  28. set fs=nothing
  29. %>
  30. <div id="content">
  31. <table class="tborder" align="center" border="0" cellpadding="6" cellspacing="1" width="100%">
  32. <tbody><tr>
  33.     <td class="trow1" width="77%">
  34.         <table border="0" cellpadding="0" cellspacing="0">
  35.             <tbody><tr valign="bottom">
  36.                 <td width="100%">
  37. <div class="navigation">
  38. <a href="/default.asp" title="3GP Forum Cepte film izleyin" alt="3GP Forum Cepte film izleyin">3gpindir.com Forum</a> Türkiye'nin En Büyük 3GP Film Sitesi
  39. </div>
  40. </td>
  41. </tr>
  42. </tbody></table>
  43. </div>
  44. </td>
  45. <!--#include file="menu.asp"-->
  46. </tr>
  47. </tbody></table>
  48. <br>
  49. <table width="100%" align="center" border="0">
  50. <tbody><tr>
  51. <td valign="top" width="180">
  52. <table class="tborder" border="0" cellpadding="6" cellspacing="1">
  53.     <tbody><tr>
  54.         <td class="thead"><strong>Menu</strong></td>
  55.     </tr>
  56.     <tr>
  57.         <td class="trow1 smalltext"><a href="/admin_category.asp">Kategoriler</a></td>
  58.  
  59.     </tr>
  60.     <tr>
  61.         <td class="trow1 smalltext"><a href="/admin_thebot.asp">Robot ayarlari</a></td>
  62.  
  63.     </tr>
  64.     <tr>
  65.         <td class="trow1 smalltext"><a href="/admin_system.asp">Sistem</a></td>
  66.  
  67.     </tr>
  68.     <tr>
  69.         <td class="trow1 smalltext"><a href="/admin_mailsend.asp">Toplu Mail</a></td>
  70.  
  71.     </tr>
  72.     <tr>
  73.         <td class="trow1 smalltext"><a href="/admin_backup.asp">DB Backup</a></td>
  74.  
  75.     </tr>
  76.     <tr>
  77.         <td class="trow1 smalltext"><a href="/admin_statics.asp">İstatistikler</a></td>
  78.  
  79.     </tr>
  80. <tr>
  81.     <td class="tcat">
  82.         <div><span class="smalltext"><strong>Uye Islemleri</strong></span></div>
  83.     </td>
  84. </tr>
  85.     <tr><td class="trow1 smalltext"><a href="/admin_users.asp?islem=ara">Uye Ara</a></td></tr>
  86.     <tr><td class="trow1 smalltext"><a href="/uyeler.asp">Uye Listesi</a></td></tr>
  87.     <tr><td class="trow1 smalltext"><a href="/admin_banned.asp">Cezali Uyeler</a></td></tr>
  88.     <tr>
  89.     </tr><tr>
  90.     <td class="tcat">
  91.         <div><span class="smalltext"><strong>Forum</strong></span></div>
  92.  
  93.     </td>
  94. </tr>
  95.     <tr><td class="trow1 smalltext">
  96.         <div><a href="/admin_forums.asp?getir=konu">Konular</a></div>      
  97.     </td></tr>
  98.     <tr><td class="trow1 smalltext">
  99.         <div><a href="/admin_forums.asp?getir=cevap">Cevaplar</a></div>    
  100.     </td></tr>
  101. </tbody>
  102. </table>
  103. </td>
  104. <td valign="top">
  105. <table class="tborder" border="0" cellpadding="6" cellspacing="1">
  106. <tbody><tr>
  107. <td class="thead" colspan="2"><strong>BackUP</strong></td>
  108. </tr>
  109. <tr>
  110. <td class="trow1" width="100%">
  111.  
  112.  
  113.  
  114.  
  115. <% If Request.QueryString("Action")="" then %>
  116. <form method="post" action="<%=Request.ServerVariables("script_name")%>?Action=DoBackup">
  117. <input type="hidden" name="strServer" value="<%=mysqlhost%>">
  118. <input type="hidden" name="strDatabase" value="<%=mysqlvt%>">
  119. <input type="hidden" name="strDBUser" value="<%=mysqlkadi%>">
  120. <input type="hidden" name="strDBPass" value="<%=mysqlsifre%>">
  121. <input type="hidden" name="strBackupFolder" value="<%=strBackupFolder%>">
  122. <input type="hidden" name="strBackupFileName" value="<%=strBackupFileName%>">
  123. <input type="submit" value="[ RUN BACKUP SYSTEM ]" onclick="Ac('bekleyin');">
  124. <br><br>
  125. İşlem Süresi : <%=kalanzaman%> saniye
  126. </form>
  127.  
  128.  
  129.  
  130.  
  131. <%
  132. elseif Request.QueryString("Action") = "DoBackup" Then
  133.  
  134. Set edit=sur.Execute("update site Set durum=1,sonyedek='"&strBackupFileName&"',kalansure='"&kalanzaman&"' WHERE id ='1'")
  135. response.write("Islem boyunca gececek sure : "&kalansure&"<br>Son Yedek Adi : "&koigbg&"<br>Site Erisimi : Kapali<br><br>")
  136.  
  137. strServer = Request.Form("strServer")
  138. strDatabase = Request.Form("strDatabase")
  139. strDBUser = Request.Form("strDBUser")
  140. strDBPass = Request.Form("strDBPass")
  141. strBackupFolder = Request.Form("strBackupFolder")
  142. strBackupFileName = Request.Form("strBackupFileName")
  143.  
  144. Call BackupDatabase
  145. elseif Request.QueryString("Action") = "Download" Then
  146. Call DownloadFile(ConvertSlash(Request("FilePath")))
  147. end if
  148.  
  149. Function BackupDatabase
  150.     Set FSO = CreateObject("Scripting.FileSystemObject")
  151.    
  152.     Set nnFile = FSO.CreateTextFile(strBackupFolder & strBackupFileName)
  153.  
  154.     nnFile.WriteLine("/*")
  155.     nnFile.WriteLine(AppName)
  156.     nnFile.WriteLine("Source Host : " & strServer)
  157.     nnFile.WriteLine("Source Database : " & strDatabase)
  158.     nnFile.WriteLine("Date : " & Now())
  159.     nnFile.WriteLine("*/")
  160.     nnFile.WriteBlankLines(1)
  161.  
  162.  
  163.     set Conn = server.CreateObject("ADODB.connection") 
  164.     Conn.Open "DRIVER={MySQL ODBC 3.51 Driver};server="& strServer &";uid="& strDBUser &";pwd="& strDBPass &";database="& strDatabase &";option=3;"
  165.        
  166.     Set DBTables = Conn.OpenSchema(20)
  167.  
  168.     Do While Not DBTables.Eof
  169.  
  170.         If  DBTables("table_type")="TABLE" Then
  171.  
  172.             Set rs = Server.CreateObject("ADODB.RecordSet")
  173.             rs.Open "SELECT * FROM "& DBTables("table_name") &" ", Conn, 1, 3
  174.  
  175.             'Set rs = Conn.Execute("SELECT * FROM "& DBTables("table_name") &" ")
  176.             '===========
  177.  
  178.             nnFile.WriteLine("drop table if exists "& DBTables("table_name") &";")
  179.             nnFile.WriteLine("CREATE TABLE `"& DBTables("table_name") &"` (")
  180.  
  181.                 TotalField = 0
  182.                 For Each Field in Rs.Fields
  183.                     If Field.Properties("ISAUTOINCREMENT") = True then
  184.                         PK_Name = Field.Name
  185.                         nnFile.WriteLine(Chr(9) & "`"& Field.Name &"` "& MySQLTypeDescription(Field.Type,Field.DefinedSize) &" NOT NULL auto_increment,")
  186.                     Else
  187.                         If CInt(Field.Type) = 204 Or CInt(Field.Type) = 205 Then
  188.                             nnFile.WriteLine(Chr(9) & "`"& Field.Name &"` "& MySQLTypeDescription(Field.Type,Field.DefinedSize) &",")
  189.                         Else
  190.                             nnFile.WriteLine(Chr(9) & "`"& Field.Name &"` "& MySQLTypeDescription(Field.Type,Field.DefinedSize) &" default NULL,")
  191.                         End If
  192.                     End If 
  193.                    
  194.                     TotalField = TotalField + 1
  195.                 Next
  196.  
  197.             nnFile.WriteLine(Chr(9) & "PRIMARY KEY  (`"& PK_Name &"`)")
  198.             nnFile.WriteLine(Chr(9) & ") ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_turkish_ci;")
  199.             nnFile.WriteBlankLines(1)
  200.  
  201.             '============
  202.  
  203.             Do While Not rs.Eof
  204.                 nnFile.Write("INSERT INTO `"& DBTables("table_name") &"` VALUES (")
  205.                 ThisField = 0
  206.                 For Each Field in Rs.Fields
  207.                     If IsNumeric(Field.Value) Then
  208.                         nnFile.Write(Field.Value)
  209.                     ElseIf Field.Value <> "" Then
  210.                         nnFile.Write("'" & FormatData(Field.Value) & "'")
  211.                     Else
  212.                         nnFile.Write("NULL")
  213.                     End If
  214.  
  215.                     ThisField = ThisField + 1
  216.  
  217.                     If ThisField < TotalField Then nnFile.Write(",")                   
  218.                 Next
  219.                 nnFile.Write(");")
  220.                 nnFile.Write(vbNewLine)
  221.             rs.MoveNext
  222.             Loop
  223.  
  224.             nnFile.WriteBlankLines(1)
  225.  
  226.         rs.Close
  227.         Set Rs = Nothing
  228.  
  229.         End If
  230.     DBTables.MoveNext : Loop
  231.     DBTables.Close : Set DBTables = Nothing
  232.  
  233.     nnFile.Close
  234.     Set FSO = Nothing
  235.  
  236.     Set edit=sur.Execute("update site Set durum=0 WHERE id ='1'")
  237.     Response.Write "<input type=""button"" value=""[ DOWNLOAD BACKUP FILE ]"" onclick=""location.href='?Action=Download&FilePath="& ConvertSlash(strBackupFolder & strBackupFileName) &"'"">"
  238.  
  239. End Function
  240.  
  241. '######################################
  242. Function FormatData(data)
  243.     If data <> "" Then
  244.         data = Replace(data,Chr(39),Chr(180))
  245.     End If
  246.     FormatData = data
  247. End Function
  248.  
  249. Function MySQLTypeDescription(x,y)
  250.     Select Case X
  251.    
  252.         Case 2      Y = "smallint"
  253.         Case 3      Y = "int(11)" 'int yada mediumint yada integer
  254.         Case 4      Y = "float"
  255.         Case 5      Y = "double" 'double yada real
  256.         Case 16     Y = "tinyint"
  257.         Case 18     Y = "year"
  258.         Case 20     Y = "bigint(20)"
  259.         Case 129    Y = "enum" 'enum yada set
  260.         Case 131    Y = "decimal(10,0)" 'decimal yada numeric
  261.         Case 133    Y = "date"
  262.         Case 134    Y = "time" 
  263.         Case 135    Y = "datetime" 'datetime yada timestamp
  264.         Case 200    Y = "varchar("& y &")  collate utf8_turkish_ci" 'varchar yada char yada tinytext
  265.         Case 201    Y = "longtext collate utf8_turkish_ci" 'text yada mediumtext yada longtext => Accessteki NOT'un karşılığı aralarındaki farkı boyutları belirliyor
  266.         Case 204    Y = "tinyblob"
  267.         Case 205    Y = "longblob" 'blob yada mediumblob yada longblob => aralarındaki farkı sadece boyutları belirliyor.
  268.     End Select
  269.  
  270.     MySQLTypeDescription = Y
  271. End Function
  272.  
  273. Function DownloadFile(FilePath)
  274.     Response.Clear
  275.     Set FSO = CreateObject("Scripting.FileSystemObject")
  276.     Set objFile = FSO.GetFile(FilePath)
  277.     intFilelength = objFile.Size
  278.     Set objStream = Server.CreateObject("ADODB.Stream")  
  279.     objStream.Open  
  280.     objStream.Type = 1
  281.     objStream.LoadFromFile(FilePath)
  282.                        
  283.     Response.AddHeader "Content-Disposition" , "attachment; filename=" & objFile.Name  
  284.     Response.AddHeader "Content-Length" , intFilelength  
  285.     Response.CharSet = "UTF-8"  
  286.     Response.ContentType = "application/octet-stream"    
  287.     Response.BinaryWrite objStream.Read  
  288.     Response.Flush
  289.     Response.End
  290.     objFile.Close : Set objFile = Nothing
  291.     objStream.Close : Set objStream = Nothing
  292.     Set FSO = Nothing
  293. End Function
  294.  
  295. Function ConvertSlash(strURL)
  296.     ConvertSlash = Replace(strURL,"\","/")
  297. End Function
  298. %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement