using System; using System.Net; namespace cShapNslookup { class Program { static void Main(string[] args) { string HostName = ""; HostName = "www.naver.com"; //실제 name 을 가져오기 위해 IPHostEntry을 이용 IPHostEntry hostEntry = Dns.GetHostByName(HostName); Console.WriteLine("실제이름 : " + hostEntry.HostName + ""); //IP 주소를 찾아서 출력함 foreach (IPAddress ip in hostEntry.AddressList) { Console.WriteLine(ip.ToString()); } } } }
13. 5. 29.
C# DNS로 아이피 알아내기
13. 5. 21.
Classic ASP Email 전송
<% ' Mail 발송 Function eMailCDOSend(MailTitle, MailTag, Sender, Receiver) ' MailTitle : 제목 ' MailTag : html내용 ' Sender : 보내는 사람 ' Receiver : 받는사람 ' 2008서버 이상 에서 발송하는 환경정보 설정 Dim eMailObject, eMailConfig Set eMailObject = Server.CreateObject("CDO.Message") Set eMailConfig = Server.CreateObject("CDO.Configuration") Dim SchemaPath : SchemaPath = "http://schemas.microsoft.com/cdo/configuration/" With eMailConfig.Fields .Item (SchemaPath & "sendusing") = 2 'CDOSendUsingPort .Item (SchemaPath & "smtpserver") = "127.0.0.1" 'CDOSendUsingPort [ServerIP] .Item (SchemaPath & "smtpserver") = "localhost" 'CDOSendUsingPort .Item (SchemaPath & "smtpserverport") = "25" 'Port .Update End With eMailObject.Configuration = eMailConfig Set eMailConfig = Nothing With eMailObject .From = Sender .To = Receiver .Subject = MailTitle .HTMLBody = MailTag ' .HTMLBodyPart.Charset = "Utf-8" .Send End With Set eMailObject = Nothing End Function %>
Class ASP 에서 사이트 소스 긁어오기
<% '페이지로드Post방식 Function getSiteSourcePost( siteURL, params ) Set httpObj = Server.CreateObject("WinHttp.WinHttpRequest.5.1") httpObj.open "POST" , siteURL, False httpObj.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded" '포스트 방식시 위의 라인을 추가해 주어야 한다. httpObj.Send params '포스트의 파라미터는 Send 호출시 같이 값을 넘겨 주어야 한다. httpObj.WaitForResponse If httpObj.Status = "200" Then getSiteSourcePost = httpObj.ResponseText Else getSiteSourcePost = null End If End Function '페이지로드 get방식 Function getSiteSourceGet( siteURL, params ) Set httpObj = Server.CreateObject("WinHttp.WinHttpRequest.5.1") httpObj.open "GET", siteURL & "?" & params, False httpObj.Send() httpObj.WaitForResponse If httpObj.Status = "200" Then getSiteSourceGet = httpObj.ResponseText Else getSiteSourceGet = null End If End Function '네이버 response.write(getSiteSourcePost("http://www.naver.com","")) '다음 response.write(getSiteSourcePost("http://www.daum.net","")) %>
Classic ASP HTML 태그 제거
'태그제거 function StripTags( htmlDoc ) dim rex set rex = new Regexp rex.Pattern= "<[^>]+>" rex.Global=true StripTags =rex.Replace(htmlDoc,"") end function html = "<a href=""http://2nusa.blogspot.kr/""><b>Hello My World</b></a>" response.write(StripTags(html ))
MS-SQL 테이블 정보 얻는 쿼리(테이블스키마)
SELECT A.TABLE_NAME, C.VALUE AS TABLE_COMMENT, A.COLUMN_NAME, A.DATA_TYPE, ISNULL(CAST(A.CHARACTER_MAXIMUM_LENGTH AS VARCHAR), CAST(A.NUMERIC_PRECISION AS VARCHAR) + ',' + CAST(A.NUMERIC_SCALE AS VARCHAR)) AS COLUMN_LENGTH, A.COLUMN_DEFAULT, A.IS_NULLABLE, B.VALUE AS COLUM_COMMENT FROM INFORMATION_SCHEMA.COLUMNS A LEFT OUTER JOIN SYS.EXTENDED_PROPERTIES B ON B.major_id = object_id(A.TABLE_NAME) AND A.ORDINAL_POSITION = B.minor_id LEFT OUTER JOIN (SELECT object_id(objname) AS TABLE_ID, VALUE FROM ::FN_LISTEXTENDEDPROPERTY (NULL, 'User','dbo','table',NULL, NULL, NULL)) C ON object_id(A.TABLE_NAME) = C.TABLE_ID WHERE A.TABLE_NAME = '테이블명' ORDER BY A.TABLE_NAME, A.ORDINAL_POSITION
13. 5. 19.
13. 5. 15.
MS-SQL Database 이동 및 로그용량 관리
USE master --sql 목록제거 EXEC sp_detach_db 'DB명', 'true' --C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data --DB파일,DB_log파일 d:\SQL DATA\로 이동 --sql 목록추가 EXEC sp_attach_db @dbname = N'DB명', @filename1 = N'd:\SQL Data\DB명.mdf', @filename2 = N'd:\SQL Data\DB명_log.ldf' --sql 로그용량 줄이기 use DB명 backup log DB명 with no_log dbcc shrinkfile('DB명_log', 50) -- 트렌젝션 로그사이즈 제한 dbcc shrinkdatabase(db명,1000)
-- 로그용량 줄이기 USE [DB명]; GO ALTER DATABASE DB명 SET RECOVERY SIMPLE; GO DBCC SHRINKFILE ('DB명_Log', 10); GO ALTER DATABASE DB명 SET RECOVERY FULL;
13. 5. 14.
C# 컴퓨터 재부팅 및 끄기
프로젝트 << 참조 << .NET << System.Management 추가
나머지는 알아서 추가 ㅡ.ㅡ;;
나머지는 알아서 추가 ㅡ.ㅡ;;
public partial class Form1 : Form { [DllImport("user32.Dll")] public static extern int SystemParametersInfo(int uAction, int uparam, string lpvParam, int fuWinIni); public Form1() { InitializeComponent(); } public enum ShutDown { LogOff = 0, Shutdown = 1, Reboot = 2, ForcedLogOff = 4, ForcedShutdown = 5, ForcedReboot = 6, PowerOff = 8, ForcedPowerOff = 12 } private void button1_Click(object sender, EventArgs e) { // 컴퓨터 재시작 // shutDown(ShutDown.ForcedReboot); // 컴퓨터 끄기 // shutDown(ShutDown.ForcedShutdown); } // 끄기모드 private void shutDown(ShutDown flag) { ManagementBaseObject outParam = null; ManagementClass sysOS = new ManagementClass("Win32_OperatingSystem"); sysOS.Get(); // enables required security privilege. sysOS.Scope.Options.EnablePrivileges = true; // get our in parameters ManagementBaseObject inParams = sysOS.GetMethodParameters("Win32Shutdown"); // pass the flag of 0 = System Shutdown inParams["Flags"] = flag; inParams["Reserved"] = "0"; foreach (ManagementObject manObj in sysOS.GetInstances()) { outParam = manObj.InvokeMethod("Win32Shutdown", inParams, null); } } }
13. 5. 12.
Classic ASP 영상파일 이미지추출
Set Executor = Server.CreateObject("ASPExec.Execute") fileUrl = "d:\file\abc.avi" if fs.FileExists(fileUrl) then VideoimgName = fs.getfilename(fileUrl) VideoimgNameArr = split(VideoimgName,".") if isArray(VideoimgNameArr) then vFileName = "v" & mid(VideoimgNameArr(0),2) Executor.Application = "ffmpeg -y -i " & fileUrl & " -vframes 1 -ss 00:00:02 -an -vcodec png -f rawvideo -s 400*300 d:\file\videoimg\" & vFileName & ".png" Executor.Parameters = "" strResult = Executor.ExecuteDosApp vImg = "'/file/videoimg/"& vFileName & ".png'" end if end if
13. 5. 11.
Classic ASP 모바일 체크
dim u,b,v set u=Request.ServerVariables("HTTP_USER_AGENT") set b=new RegExp set v=new RegExp b.Pattern="android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino" v.Pattern="1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-" b.IgnoreCase=true v.IgnoreCase=true b.Global=true v.Global=true if b.test(u) or v.test(Left(u,4)) then Response.Write("모바일페이지입니다.") end if
Javascript 모바일과 PC 체크하는 법
var UserAgent = navigator.userAgent; var ConType = ""; // 모바일 체크 if (UserAgent.match(/iPhone|iPod|Android|Windows CE|BlackBerry|Symbian|Windows Phone|webOS|Opera Mini|Opera Mobi|POLARIS|IEMobile|lgtelecom|nokia|SonyEricsson/i) != null || UserAgent.match(/LG|SAMSUNG|Samsung/) != null){ ConType = "mobile"; }else{ ConType = "PC"; } alert(ConType);
13. 5. 10.
Classic ASP 와 MS-SQL 연동
<OBJECT RUNAT="server" PROGID=ADODB.Connection id="ObjConn"> </OBJECT> <% dim fs,objFile dim ObjSql ,WhereSql ,Rs,i,ListArr dim Field0,Field1,,Field2,Field3,Field4 dim Val1, Val12,Url dim intNowPage ,intPageSize ,intBlockPage Set fs = Server.CreateObject("Scripting.FileSystemObject") Set objFile = fs.OpenTextFile("c:\DB_file.dat",1) ' c:\DB_file.dat 내용 ' Provider=SQLOLEDB.1;User ID=sa;Password=1111;Initial Catalog=master;Data Source=123.123.123.123,1433 ObjConn.open objFile.readline Val1 = Request.QueryString("Val1") Val2 = Request.QueryString("Val2") If Val1<>"" and Val12<>"" Then WhereSql = " WHERE " & Val1 & "='" & Val2 & & "'" Url = "&Val1=" & Val1 & "&Val2 =" & Val2 End If ObjSql = "SELECT * FROM DB_TABLE" & WhereSql Set Rs=ObjConn.Execute(ObjSql) If Not Rs.Eof Then ListArr = Rs.Getrows ' DB를 ListArr 에 저장 Rs.Close Set Rs=Nothing intNowPage = Request.QueryString("page") ' 현제페이지 intPageSize = 10 ' 페이지크기 intBlockPage = 10 ' 페이지묶음크기 If Len(intNowPage) = 0 Then ' 현제페이지값이없을경우 intNowPage = 1 End If If isArray(ListArr) then ' 목록이 있을경우 페이지 수 intTotalCount = Ubound(ListArr,2)+1 If (intTotalCount Mod intPageSize)=0 Then intTotalPage = int(intTotalCount/intPageSize) Else intTotalPage = int(intTotalCount/intPageSize)+1 End if End if If isArray(ListArr) Then '자료 있다면 변수에 저장 ' 페이지 나눌경우(없을경우 0 To Ubound(ListArr,2)) For i=0+(intNowPage*intPageSize-intPageSize) to (intNowPage*intPageSize)-1 If i<=Ubound(ListArr,2) then Field0 = ListArr(0,i) Field1 = ListArr(1,i) Field2 = ListArr(2,i) Field3 = ListArr(3,i) Field4 = ListArr(4,i) End If Next ' 페이지 나누기 If isArray(ListArr) Then intTemp = Int((intNowPage - 1) / intBlockPage) * intBlockPage + 1 If intTemp = 1 Then Response.Write("◀") Else Response.Write("<a href=""?page=" & intTemp - intBlockPage & Url & """>◀</a>") End If intLoop = 1 Do Until intLoop > intBlockPage Or intTemp > intTotalPage If intTemp = CInt(intNowPage) Then Response.Write("<font size= 3><b>" & intTemp &"</b></font> " ) Else Response.Write("<a href=""?page=" & intTemp &url &""">" & intTemp& "</a> ") End If intTemp = intTemp + 1 intLoop = intLoop + 1 Loop If intTemp > intTotalPage Then Response.Write("▶") Else Response.Write("<a href=""?page=" & intTemp & Url & """>▶</a>") End If End if %>
라벨:
웹,
Classic ASP,
MSSQL
피드 구독하기:
글 (Atom)