C#使用Pop3接收邮件的类

[不指定 2007/08/13 14:34 | by ipaddr ]

支持SSL,请点击此处下载 [file]attachment/200708/pop3mailclient.rar[/file]

使用C#做MX记录查询

[不指定 2007/08/13 14:30 | by ipaddr ]

using System;
using System.Collections;
using System.ComponentModel;
using System.Runtime.InteropServices;

//How to use
//string[] s= MXSearch.GetMXRecords("eit.name");
//foreach (string st in s)
//Console.WriteLine("Server: {0}",st);

namespace Eit.Name.Bcomcn
{
    class MXSearch
    {
        public MXSearch()
        {
        }

        #region importDll

        [DllImport("dnsapi", EntryPoint = "DnsQuery_W", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
        private static extern int DnsQuery([MarshalAs(UnmanagedType.VBByRefStr)]ref string pszName, QueryTypes wType, QueryOptions options, int aipServers, ref IntPtr ppQueryResults, int pReserved);

        [DllImport("dnsapi", CharSet = CharSet.Auto, SetLastError = true)]
        private static extern void DnsRecordListFree(IntPtr pRecordList, int FreeType);

        #endregion


        public static string[] GetMXRecords(string domain)
        {

            IntPtr ptr1 = IntPtr.Zero;
            IntPtr ptr2 = IntPtr.Zero;
            MXRecord recMx;
            if (Environment.OSVersion.Platform != PlatformID.Win32NT)
            {
                throw new NotSupportedException();
            }
            ArrayList list1 = new ArrayList();
            int num1 = MXSearch.DnsQuery(ref domain, QueryTypes.DNS_TYPE_MX, QueryOptions.DNS_QUERY_BYPASS_CACHE, 0, ref ptr1, 0);
            if (num1 != 0)
            {
                throw new Win32Exception(num1);
            }
            for (ptr2 = ptr1; !ptr2.Equals(IntPtr.Zero); ptr2 = recMx.pNext)
            {
                recMx = (MXRecord)Marshal.PtrToStructure(ptr2, typeof(MXRecord));
                if (recMx.wType == 15)
                {
                    string text1 = Marshal.PtrToStringAuto(recMx.pNameExchange);
                    list1.Add(text1);
                }
            }
            MXSearch.DnsRecordListFree(ptr2, 0);
            return (string[])list1.ToArray(typeof(string));
        }

        private enum QueryOptions
        {
            DNS_QUERY_ACCEPT_TRUNCATED_RESPONSE = 1,
            DNS_QUERY_BYPASS_CACHE = 8,
            DNS_QUERY_DONT_RESET_TTL_VALUES = 0x100000,
            DNS_QUERY_NO_HOSTS_FILE = 0x40,
            DNS_QUERY_NO_LOCAL_NAME = 0x20,
            DNS_QUERY_NO_NETBT = 0x80,
            DNS_QUERY_NO_RECURSION = 4,
            DNS_QUERY_NO_WIRE_QUERY = 0x10,
            DNS_QUERY_RESERVED = -16777216,
            DNS_QUERY_RETURN_MESSAGE = 0x200,
            DNS_QUERY_STANDARD = 0,
            DNS_QUERY_TREAT_AS_FQDN = 0x1000,
            DNS_QUERY_USE_TCP_ONLY = 2,
            DNS_QUERY_WIRE_ONLY = 0x100
        }

        private enum QueryTypes
        {
            DNS_TYPE_MX = 15
        }

        [StructLayout(LayoutKind.Sequential)]
        private struct MXRecord
        {
            public IntPtr pNext;
            public string pName;
            public short wType;
            public short wDataLength;
            public int flags;
            public int dwTtl;
            public int dwReserved;
            public IntPtr pNameExchange;
            public short wPreference;
            public short Pad;
        }


    }
}

Apply Google Apps

[不指定 2007/08/10 23:11 | by ipaddr ]

一直想弄个Google Host来玩玩,以前申请过N次,都被拒绝,Google老是玩这招,不让你那么容易得到,象以前的Gmail.

前几天登录到Gmail,退出后,发现有一个Google Apps的链接,点击去一看,很不错的东东,就是以前的Host服务,现在改名叫Apps了。马上开始申请。

目前还不支持.cn的域名,尝试用eit.name可以通过,但在最3步时,无论选择哪个国家,都提示你不支持,真是郁闷,Google有时还真是无理呢。

后来想想,可能是根据IP来判断的,暂时不对中国用户开放,于是马上登录到美国的服务器,再次申请,一切顺利,哈哈哈哈哈。。。。。。。。。。。。。。。。。。。

解析好eit.name的域名后,会在48小时内生效,可以开通100个用户的使用。真开心。。。。。。。。。。。。

Google真是好东西,最担心就是被封锁。

--------------------------------------------
2009.2更新
--------------------------------------------
目前cn域名仍不能注册,但在注册时,填写域名用xxx.CN (大写CN)也同样可以注册。
如果你从Confluence1.4.X转向Confluence2.1.x,理由很充分,因为2.0提供了一个非常棒的WYSIWYG的界面(所见即所得的界面)。
少废话,破解也是非常简单,首先下载
http://www.blogjava.net/Files/openssl/confluence2.1.4_keygen.rar
然后,解压atlassian-extras-0.7.15.jar到Confluence目录
比如:
D:\confluence-2.1.4-std\confluence\WEB-INF\lib
(覆盖掉这个目录下的atlassian-extras-0.7.xx.jar文件)
然后,
D:\confluence-2.1.4-std\confluence\WEB-INF\lib>java keygen
Keygen for Confluence.
created by TEAM dir/ZWT.
Enter your organization name: aaa
Your license key is:
ORRrxbmEJpuFSekHXocsPbpfRqsQjBdeSELeaoRdsdHcqi
mi2KeNSsv9lIO5c4yNfRqQSd2Keusdo7ufu0TKLYqRuKIa
MmURQnoPmnPprrNpURoNoMPRrnQqQNxtwstqnpQmMPurUn
nqrouunrpvvqUnnqrouunrpvvqUXXXUvssssss


运行Confluence(按照confluence install instruction)
输入上面蓝色的key,即可运行Confluence2.0
2.0感觉很美妙,比1.4强很多。
鉴于直接提供破解文件会影响Blogjava,所以我提供了一个经过加密的破解包
有需要并用于研究性质的朋友请回复Email地址。

MS Jet SQL for Access 2000中级篇

[不指定 2007/08/09 19:23 | by ipaddr ]

该系列的文章解释了什么是Microsoft? Jet SQL,并说明了它如何在Access 2000的应用程序中使用。本文是基础、中级和高级三篇中的第二篇。这些文章循序渐进的说明了使用Jet SQL的语法和一些方法,并示范了对于Access 2000来说较新的Jet SQL的特征。最后,本文的所有SQL参考都是针对Microsoft Jet 4.0 数据引擎所用的。

c#操作ACCESS数据库

[不指定 2007/08/09 14:43 | by ipaddr ]

手头没有Microsoft Access,如何建立数据库,一切依然简单.
首先引用C:\Program Files\Common Files\System\ado\msadox.dll,该DLL包含ADOX命名空间;
接着引用C:\Program Files\Common Files\System\ado\msjro.dll,该DLL包含JRO命名空间
注意:如,导入dll不成功,手动把com组件导入为 .net组件,在用vs.net工具导入 

using System;
using System.IO;
using ADOX; //该命名空间包含创建ACCESS的类(方法)--解决方案 ==> 引用 ==> 添加引用 ==> 游览找到.dll
using JRO; //该命名空间包含压缩ACCESS的类(方法)

public class Access
...{
/**////根据指定的文件名称创建ACCESS数据库
///mdbPath:要创件的ACCESS绝对路径
public void Create( string mdbPath )
...{
if( File.Exists(mdbPath) ) //检查数据库是否已存在
...{
throw new Exception("目标数据库已存在,无法创建");
}
// 可以加上密码,这样创建后的数据库必须输入密码后才能打开
mdbPath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mdbPath;
// 创建一个CatalogClass对象的实例,
ADOX.CatalogClass cat = new ADOX.CatalogClass();
// 使用CatalogClass对象的Create方法创建ACCESS数据库
cat.Create(mdbPath);
}

/**////压缩修复ACCESS数据库,mdbPath为数据库绝对路径
public void Compact( string mdbPath )
...{
if( !File.Exists(mdbPath) ) //检查数据库是否已存在
...{
throw new Exception("目标数据库不存在,无法压缩");
}
//声明临时数据库的名称
string temp = DateTime.Now.Year.ToString();
temp += DateTime.Now.Month.ToString();
temp += DateTime.Now.Day.ToString();
temp += DateTime.Now.Hour.ToString();
temp += DateTime.Now.Minute.ToString();
temp += DateTime.Now.Second.ToString() + ".bak";
temp = mdbPath.Substring(0, mdbPath.LastIndexOf("\")+1) + temp;
//定义临时数据库的连接字符串
temp2 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + temp;
//定义目标数据库的连接字符串
mdbPath2 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mdbPath;
//创建一个JetEngineClass对象的实例
JRO.JetEngineClass jt = new JRO.JetEngineClass();
//使用JetEngineClass对象的CompactDatabase方法压缩修复数据库
jt.CompactDatabase( mdbPath2, temp2 );
//拷贝临时数据库到目标数据库(覆盖)
File.Copy( temp, mdbPath, true );
//最后删除临时数据库
File.Delete( temp );
}

/**//// 备份数据库,mdb1,源数据库绝对路径; mdb2: 目标数据库绝对路径
public void Backup( string mdb1, string mdb2 )
...{
if( !File.Exists(mdb1) )
...{
throw new Exception("源数据库不存在");
}
try
...{
File.Copy( mdb1, mdb2, true );
}
catch( IOException ixp )
...{
throw new Exception(ixp.ToString());
}
}

/**////恢复数据库,mdb1为备份数据库绝对路径,mdb2为当前数据库绝对路径
public void Recover( string mdb1, string mdb2 )
...{
if( !File.Exists(mdb1) )
...{
throw new Exception("备份数据库不存在");
}
try
...{
File.Copy( mdb1, mdb2, true );
}
catch( IOException ixp )
...{
throw new Exception(ixp.ToString());
}
}
}

Getting The Real IP Of Your Users

[不指定 2007/08/06 15:52 | by ipaddr ]

There are a lot of sites around the internet that try and get your IP address. Most of their reasons are legitimate. For example Google Adsense will log your IP to see where the user clicking the advert is from (and kick you off if its the same IP you logged into that account with).

However, there are some sites that try to look at your IP for various reasons but do it wrong. Rapidshare is a beatifully painful example of this. If you're on an ISP that uses a transparent proxy, RapidShare will log the proxy address instead of the actual account IP. As they limit the downloading on a per-IP basis, that means everyone using that ISP, going through that proxy, has the same IP to Rapidshare, meaning the limit to how much you download is split among those users.

Languages

  • VB.net
  • C#
  • PHP
  • Java and JSP
  • ASP/VBScript
  • ColdFusion
  • Perl

What I'm saying here is, if you're going to do your own IP lookups for whatever reason, do them correctly. My initial code here was in VB.net but since I have translated what its doing to the most popular server-side languages. As its based on the server variables, rather than the code's process, its quite easy to port to something else if you need to.

The lookup that these "incorrect" sites are doing is something like this:

Request.ServerVariables("REMOTE_ADDR")


What then need to be doing is comparing the HTTP_X_FORWARDED_FOR variable against it, to check that there isn't a non-transparent proxy in the way. Like so:


' Look for a proxy address first
Dim _ip As String = Request.ServerVariables("HTTP_X_FORWARDED_FOR")

' If there is no proxy, get the standard remote address
If (_ip = "" Or _ip.ToLower = "unknown") Then _
    _ip = Request.ServerVariables("REMOTE_ADDR")

  

This doesnt help people that are limited to (or otherwise) on anonymous proxies. They will hide the forwarding address (like they're supposed to) and therefore the lookup will ONLY get the proxy's address. Some ISPs do this by default to "protect" their users... Its just retarded. If you ISP does this, and you've been wondering why RS or other sites don't work... Now you know.

Here are some more examples in other languages:

C#


// Look for a proxy address first
String _ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
// If there is no proxy, get the standard remote address
If (_ip == "" || _ip.ToLower == "unknown")
    _ip = Request.ServerVariables["REMOTE_ADDR"];

PHP

Based on code from OxyScripts.

/**
* Call as: $userp = GetUserIP();
*/
function GetUserIP() {
    if (isset($_SERVER)) {
        if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
            return $_SERVER["HTTP_X_FORWARDED_FOR"];
       
        if (isset($_SERVER["HTTP_CLIENT_IP"]))
            return $_SERVER["HTTP_CLIENT_IP"];
        return $_SERVER["REMOTE_ADDR"];
    }
    if (getenv('HTTP_X_FORWARDED_FOR'))
        return getenv('HTTP_X_FORWARDED_FOR');
    if (getenv('HTTP_CLIENT_IP'))
        return getenv('HTTP_CLIENT_IP');
    return getenv('REMOTE_ADDR');
}

Java and JSP

String ipaddress = request.getHeader("HTTP_X_FORWARDED_FOR");
if (ipaddress  == null)
   ipaddress = request.getRemoteAddr();

ASP/VBScript


ipaddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
if ipaddress = "" then
    ipaddress = Request.ServerVariables("REMOTE_ADDR")
end if

ColdFusion


<CFCOMPONENT>
    <CFIF #CGI.HTTP_X_Forwarded_For# EQ "">
        <CFSET ipaddress="#CGI.Remote_Addr#">
    <CFELSE>
        <CFSET ipaddress="#CGI.HTTP_X_Forwarded_For#">
    </CFIF>
</CFCOMPONENT>

Perl

$IPAddress = $ENV{HTTP_X_FORWARDED_FOR};
if ($IPAddress == "") {
    $IPAddress = $ENV{HTTP_X_FORWARDED_FOR};
}

If you know anymore, just ping them in my general direction and they can be added.



操作系统linux和Unix都适用。
修改/etc/ssh/sshd_config,将里面的Port改为新端口,比如10022,然后
[code]kill -HUP `cat /var/run/sshd.pid` [/code]
就行了。现有连接自己不会断,因为
kill -HUP `cat /var/run/sshd.pid` 只是HUP监听的那个,已经建立的连接(不同的 pid)不会断。

然后你在现有账号下面exit,在用新的端口登陆就可以了!

正则表达式学习笔记

[不指定 2007/07/18 17:30 | by ipaddr ]

正则表达式学习笔记

  正则表达式(regular expression)描述了一种字符串匹配的模式,可以用来检查一个串是否含有某种子串、将匹配的子串做替换或者从某个串中取出符合某个条件的子串等。
  列目录时, dir *.txt或ls *.txt中的*.txt就不是一个正则表达式,因为这里*与正则式的*的含义是不同的。

  为便于理解和记忆,先从一些概念入手,所有特殊字符或字符组合有一个总表在后面,最后一些例子供理解相应的概念。

RHEL4.4-x86_64 + Oracle 10.2.0.1安装笔记

硬件环境:

由于是安装64位的Linux+Oracle,所以需要64位的CPU;

本文的安装环境为:

CPU:AMD Athlon64 3200+ (939)

Memory: DDR400 1G

Harddisk: IDE 80G

(鱼漂注:此文档参考了网上的资料和Oracle官方文档,并对一些错误和不必要的步骤进行了修正。)

(文档作者:鱼漂[admin.net(at)163.com] 转载请注明,文档最新版本请访问http://www.eit.name/)

分页: 31/57 第一页 上页 26 27 28 29 30 31 32 33 34 35 下页 最后页 [ 显示模式: 摘要 | 列表 ]