Archive

Archive for the ‘Network’ Category

[repost]如何“加密”你的email地址

现在在网上要小心,无论是保护好你的用户名和帐号,还是我们的电子邮件地址。在网上有很多爬虫程序专爬我们的电子邮件地址,一量被爬中了,那么你的邮箱里就是一堆又一堆的垃圾邮件,就好像我的haoel(at)hotmail.com一样,在7、8年前,每天几千封的垃圾邮件。现在hotmail的垃圾邮件过滤得好一些了,不过也有每天40封左右的垃圾邮件。但是我们在自己的网页上又需要发布自己的email地址。所以我们需要搞乱我们的邮件地址,就像那种非常规的搞乱代码一样。不过,我们还需要能认人读的出来。

一般来说,在网上现在很普遍的做法是——

  • 1)用图片,可以用PHP动态生成那个验证码式的。
  • 2)把@变成at,把点变成dot,如 haoel(at)hotmail(dot)com之类的。
  • 3)把a变成@,写成haoel@hotm@mail.com

不过这些还是能被爬到,用图片的方法不利于用户拷贝粘贴。下面介绍几种方法:

第一种:使用CSS样式

反转字序

1
2
span.codedirection { unicode-bidi:bidi-override; direction: rtl; }
<p><span>moc.liamtoh@leoah</span></p>

加入些不显示的字符串

1
2
p span.hide { display:none; }
<p>foo@bar<span class="hide">null</span>.baz</p>

第二种:使用Javascript

最为简单的方法是:

1
document.write("haoel" + "@" + "hotmail" + "." + "com");

或是:

1
2
3
4
5
6
7
8
9
<script type="text/javascript">
<!--
    var string1 = "@";
    var string2 = "haoel";
    var string3 = "hotmail.com";
    var string4 = string2 + string1 + string3;
    document.write("<a href=" + "mail" + "to:" + string2 + string1 + string3 + ">" + string4 + "</a>");
//-->
</script>

不过更为强大的是使用ROT13加密,这里有一个ROT13的在线工具,或是使用PHP的ROT13的函数str_rot13

1
2
3
4
<script type=”text/javascript”>
document.write(“<n uers=\"znvygb:unbry@ubgznvy.pbz\">”.replace(/[a-zA-Z]/g,
function(c){return String.fromCharCode((c<=”Z”?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);}));
</script>陈皓的电子邮件</a>

这些方法还是很有效果的。

About Twitter

I registered one account on Twitter which is @Woolni about few mothers ago, and then I’ve nearly forgotten it. I want to use it days ago, but I found the account has been suspended. I am very surprised, because I have never used the account before except registered it.

But I get a normal account now, I feel Twitter’s service is very nice, because you just need post them a email which describe your problems and they will be handled quickly. Thank Arite who is the administrator of Twitter, my account get normal under his help. Comparing with services in China, it needn’t to fill the wizard step by step, it’s very nice.

Though most of my friends can’t see my Tweets, I insist using it still, because I consider it to be a sticky note, I don’t care whether others notice it, just like my blog on wordpress.

My Twitter@Woolni

Delete item from List

List list = new ArrayList();  

  •         list.add("1");   
  •         list.add("2");   
  •         list.add("3");   
  •         list.add("4");   
  • for (int i = list.size() – 1; i >= 0; i–) {   
  •             list.remove(i);   
  •         }   
  • for (int i = 0; i < list.size(); i++) {   
  •             System.out.println(list.get(i));   
  •         }
  • Categories: Network Tags: ,

    [Repost] Configuring ASP.NET 2.0 Application Services to use SQL Server

    One question I’ve seen asked a few times by people over the last few weeks is “how do I setup the new ASP.NET Membership, Role Management, and Personalization services to use a regular SQL Server instead of SQL Express?” This blog entry walks you though a few simple steps on how to-do this.

    Quick Review: What are the new ASP.NET 2.0 Application Services?

    ASP.NET 2.0 includes a number of built-in “building block” application services. We call them “building blocks” because they are useful core frameworks for enabling super-common scenarios with web applications today – and as a result can provide significant productivity wins and time-savings for developers.

    They include: a membership API for managing usernames/passwords and secure credential management, a roles API that supports mapping users into logical groups, a profile API for storing arbitrary properties about both authenticated and anonymous users visiting a web site (for example: their zipcode, gender, theme preference, etc), a personalization API for storing control customization preferences (this is most often used with the WebPart features in ASP.NET 2.0), a health monitoring API that can track and collect information about the running state and any errors that occur within a web application, and a site navigation API for defining hierarchy within an application and constructing navigation UI (menus, treeviews, bread-crumbs) that can be context specific based on where the current incoming user is in the site.

    The ASP.NET Application Service APIs are designed to be pluggable and implementation agnostic, which means that the APIs do not hardcode the details of where data is stored with them. Instead, the APIs call into “providers”, which are classes that implement a specific “provider contract” – which is defined as an abstract class with a defined set of methods/properties that the API expects to be implemented.

    ASP.NET 2.0 ships with a number of built-in providers including: a SQL Express provider for going against local SQL Express Databases, SQL 2000/2005 providers that work against full-blown SQL Servers, an Active Directory Provider that can go against AD or ADAM implementations, and in the case of site navigation an XML provider that can bind against XML files on the file-system.

    The beauty of the model is that if you don’t like the existing providers that ship in the box, or want to integrate these APIs against existing data-stores you are already using, then you can just implement a provider and plug it in. For example: you might already have an existing database storing usernames/passwords, or an existing LDAP system you need to integrate with. Just implement the MembershipProvider contract as a class and register it in your application’s web.config file (details below), and all calls to the Membership API in ASP.NET will delegate to your code.

    Default SQL Express Providers

    Out of the box, most of the ASP.NET 2.0 application services are configured to use the built-in SQL Express provider. This provider will automatically create and provision a new database for you the first time you use one of these application services, and provides a pretty easy way to get started without a lot of setup hassles (just have SQL Express on the box and you are good to go). Note that SQL Express databases can also be upgraded to run in the context of full-blown SQL Server instances – so apps built using SQL Express for development can easily be upgraded into a high-volume, clustered, fail-over secure 8P SQL box when your app becomes wildly successful.

    How do I change the providers to use SQL Server Instead of SQL Express?

    If you want to use a full-blown SQL Server 2000 or SQL Server 2005 database instance instead of SQL Express, you can follow the below steps:

    Step 1: Create or obtain a blank SQL database instance

    In this step you’ll want to create or obtain a connection string to a standard SQL database instance that is empty.

    Step 2: Provision your SQL database with the ASP.NET schemas

    Open a command-line window on your system and run the aspnet_regsql.exe utility that is installed with ASP.NET 2.0 in under your C:\WINDOWS\Microsoft.NET\Framework\v2.0.xyz directory.

    Note that this utility can be run in either a GUI based mode or with command-line switches (just add a -? flag to see all switch options).

    Using this wizard you can walkthrough creating the schema, tables and sprocs for the built-in SQL providers that come with ASP.NET 2.0. The below screens show the step-by-step walkthrough of this:





    Once you have finished walking through the wizard, all the database schema + sprocs to support the application services will have been installed and configured (note: if your DBA wants to see exactly what is going on behind the covers, we also ship the raw .sql files underneath the above framework directory, and your DBA can walkthrough them and/or run them manually to install the DB).

    Step 3: Point your web.config file at the new SQL Database

    ASP.NET 2.0 now supports a new section in your web.config file called “<connectionStrings>” which (not too surprisingly) are used to store connection strings. One nice thing from an administration perspective is that the new ASP.NET Admin MMC Snap-in now provides a GUI based way to configure and manage these:

    ASP.NET 2.0 also now supports encrypting any section stored in web.config files — so you can also now securely store private data like connectionstrings without having to write any encryption code of your own. 

    ASP.NET 2.0 ships with a built-in connection string called “LocalSqlServer” which by default is configured to use a SQL Express database, and which by default the Membership, Roles, Personalization, Profile and Health Monitoring services are configured to use.

    The easiest way to have your application automatically take advantage of your newly created SQL database is to just replace the connectionstring value of this “LocalSqlServer” setting in your app’s local web.config.

    For example, if I created my database on the local machine in an “appservicesdb” database instance and was connecting using Windows Integrated security, I would change my local web.config file to specify this:

    <configuration>

    <connectionStrings>

    <remove name=”LocalSqlServer”/>

    <add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=appservicesdb;Integrated Security=True" providerName="System.Data.SqlClient"/>

    </connectionStrings>

    </configuration>

    Hit save, and all of the built-in application services are now using your newly created and defined SQL Server database.

    Note: The one downside with the above approach is that I’m re-using the “LocalSqlServer” connection string name – which will feel weird if/when I deploy my database on another machine. If I wanted to name it with my own connection string name, I could do this simply by adding a completely new connection-string, and then pointing the existing providers to use the new connection-string name in place of the default LocalSqlServer one.

    Hope this helps,

    Scott

    P.S. In some future blog post I’ll walkthrough actually using some of the above new APIs.

    Categories: Network Tags:

    奇怪的网络

    我的机器能够ping通局域网内机器和网关, 也能ping 通8.8.8.8和208.67.22.222等DNS服务器, ping不通其他公网IP. 奇怪啊!

    虚机是是安装在Virtual Box, 有XP也有windows 2003, 使用Bridge连接, 全能够正常上网., 奇怪啊!

    有高人知道什么原因吗?

    Categories: Network

    ArcGIS API For M$—Cross Domain

     

    I am studying silverlight for the next project.

    It’s a long way to display the map whitch is configed in ArcGIS server 9.3 to the webpage is CROSS DOMAIN.

    Silverlight is the same as flash, It can’t use the web services which isn’t in the same domain by default. But the solution is simple. Add a xml files to the root of the website root directory, and the problem will disappear.

    The client browser will then download the XAP file. After this point, the user might not connect back to this Web server at all but rather directly to the servers containing map content and tasks. Note that if your web application is not hosted on the same server as the ArcGIS Server, you will have to have a crossdomain.xml on the ArcGIS Server.

    About crossdomain.xml

    To access data from a different server than the one hosting your Silverlight application, the remote server needs to have a cross-domain file in the root directory. For security reasons, the Web browser cannot access data that resides outside the exact Web domain where the XAP originated. However, M$ silverlight runtime can load data across domains if permission is granted from the server. This is accomplished by including a small crossdomain.xml file on the remote server that permits Silverlight to connect to services on that server. For instance:

    <?xml version="1.0"?>
    <!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
    <cross-domain-policy>
        <site-control permitted-cross-domain-policies="all"/>
        <allow-access-from domain="*"/>
    </cross-domain-policy>

    To deploy the cross-domain file on ArcGIS Server, see the instructions specific to your platform. For .NET platform, just add crossdomain.xml to your Web server root directory, for example, C:\inetpub\wwwroot.

    Categories: Network Tags:

    Make Windows 2003 Server Stream FLV Videos

    .FLV files are already the best method for publishing video on the web, and are
    sure to become even better with the new enhancements in Flash 8. When
    serving .flv files off of a Windows Server 2003 (or any other Windows
    server I would imagine) requires setting up the MIME type on the server
    first (it isn’t one of the native MIME types on MS servers). 

    You can figure out easily if your server is configured to support
    .flv files by posting a .flv file on a server and navigating to the URL
    of that .flv in a browser. If you see a LONG string of garbage on the
    screen, your server isn’t set up for .FLVs and needs to have the MIME
    type set up.

    Adding .flv MIME type in IIS

    1) Select the site to configure in IIS, right click and select "Properties"

    2) Under HTTP Headers Tab, select "File Types" under the MIME Map section and select "New Type"

    3) Type ".flv" as the associated extension and "video/x-flv" as the content type.

    4) Select "OK" and you’re ready to fly!

    Categories: Network Tags: