ncowboy

统计

常用链接

留言簿(1)

c#

Linux

阅读排行榜

评论排行榜

2004年2月22日 #

MDK 10.1版,简单硬盘安装法(图形界面)

MDK 10.1版,简单硬盘安装法(图形界面)
1、用md5sums.exe filename.iso命令,验证ISO文件的MD5码是否正确。

2、把几个ISO文件都解压到同一个目录中,比如MDK10。由于目前MDK还不能识别ISO软件源,因此不解压ISO文件安装后,只能手工挂接ISO和安装软件,比较麻烦,因此推荐此全解压ISO文件安装法

3、将解压后的isolinuxalt0中的文件(vmlinuz,all.rdz)都复制到dosutils目录里面的autoboot中。


4、在dosutils目录中编辑一个autoboot.bat文件,内容为:(\请改成英文状态的半角斜杠"",这里我在下面命令行用了可是论坛把斜杠删除了我只有用中文全角代替)
loadlin autoboot\vmlinuz vga=788 ramdisk_size=128000 initrd=autoboot\all.rdz

5、用DOS软盘或光盘重启电脑进入dos,转到dosutils目录,运行autoboot.bat文件,

此法安装后的MDK启动检测是图形界面。
另外,大内存的可以把ramdisk_size设为256000,17寸显示器可以将vga设为791

posted @ 2005-01-19 14:36 35号房客 阅读(1057) | 评论 (1)编辑

ORACLE_SID在Linux平台是否大小敏感?是!

今天创建了一个新的oracle数据库。然后更改ORACLE_SID,但是,数据库无法启动。报无法找到“ /u01/app/oracle/product/10.1.0/db_1/dbs/initLACL.ora”文件。经过检查,我发现是因为建库时指定的sid,和环境里面的sid大小写不一直。大小写差异的缘故。实际存在“ /u01/app/oracle/product/10.1.0/db_1/dbs/initlacl.ora”文件。

posted @ 2004-11-29 18:55 35号房客 阅读(670) | 评论 (1)编辑

oracle 9i on redhat as3,应该安装的rpm

安装:
gnome-libs-1.4.1.2.90-34.1.i386.rpm
libpng10-1.0.13-8.i386.rpm

 

posted @ 2004-11-25 14:31 35号房客 阅读(1012) | 评论 (0)编辑

start isqlplus&em of oracle

start isqlplus
************************************************


[oracle@lacl-001 ~]$isqlplusctl

iSQL*Plus 10.1.0.2.0
Copyright (c) 2004 Oracle. All rights reserved.
Invalid arguments

Unknown command option
Usage::
      isqlplusctl start| stop


[oracle@lacl-001 ~]$isqlplusctl start

iSQL*Plus 10.1.0.2.0
Copyright (c) 2004 Oracle. All rights reserved.
Starting iSQL*Plus ...
iSQL*Plus started.

[oracle@lacl-001 ~]$

************************************************
start em
************************************************

[oracle@lacl-001 ~]$emctl start dbconsole

TZ set to Asia/Chungking
Oracle Enterprise Manager 10g Database Control Release 10.1.0.2.0
Copyright (c) 1996, 2004 Oracle Corporation. All rights reserved.
http://localhost:5500/em/console/aboutApplication
Starting Oracle Enterprise Manager 10g Database Control
............................... started.

------------------------------------------------------------------

Logs are generated in directory
/u01/app/oracle/product/10.1.0/db_1/lacl-001_TSH1/sysman/log
************************************************

posted @ 2004-11-25 14:27 35号房客 阅读(638) | 评论 (0)编辑

通过ftp修改帐户密码

通过ftp修改帐户密码
quote SITE PSWD "<oldpassword>" "<newpassword>".

posted @ 2004-11-25 14:25 35号房客 阅读(1047) | 评论 (4)编辑

学会将SYS_GUID和序列作为主关键字

学会将SYS_GUID和序列作为主关键字
ZDNet China
10/11/2003
URL: http://www.zdnet.com.cn/developer/tech/story/0,2000081602,39178163,00.htm

本文译自Builder.com,未经许可请勿转载
Oracle8i引入了SYS_GUID这个概念,它同Oracle管理员所使用的传统的序列(sequence)相比具有诸多优势。一个序列生成器只是简单地创建从给定的起点开始的一系列整数值,而且它被用在选择陈述式的时候自动地递增该系列。

序列生成器所生成的数字只能保证在单个实例里是唯一的,这就不适合将它用作并行或者远程环境里的主关键字,因为各自环境里的序列可能会生成相同的数字,从而导致冲突的发生。SYS_GUID会保证它创建的标识符在每个数据库里都是唯一的。

此外,序列必须是DML陈述式的一部分,因此它需要一个到数据库的往返过程(否则它就不能保证其值是唯一的)。SYS_GUID源自不需要对数据库进行访问的时间戳和机器标识符,这就节省了查询的消耗。

create table use_seq_table(id integer);
create sequence use_seq_sequence;
insert into use_seq_table values (use_seq_sequence_value.nextval);

REM - for some reason, the documentation uses raw(32)
create table use_guid_table(id raw(16));
insert into use_guid_table(sys_guid());

很多应用程序都依靠序列生成器来创建数据行的主关键字,这些数据行没有一个明显的主值,这也就是说,在这样的数据集里一条记录的创建就会让数据列发生改变。因此,管理员可能会对在表格中将SYS_GUID用作主关键字而不使用序列数感兴趣。这在对象在不同机器的不同数据库里生成以及需要在后来合并到一起的情况下很有用。

但是,SYS_GUID所生成的值是一个16位的原始值。序列所生成的整数不会使用16位(的值),除非它达到了10的30次方(每个字节有两位),而且数字是相当独特的:

SQL> select dump(123456789012345678901234567890) from dual;

DUMP(123456789012345678901234567890)

--------------------------------------------------------------
Typ=2 Len=16: 207,13,35,57,79,91,13,35,57,79,91,13,35,57,79,91

较短的值就意味着用于表格和索引的存储空间更少,以及查询访问的时间更短。

使用SYS_GUID或者序列会在数据库使用周期里的某些地方造成性能上的消耗;问题就是在哪里。对于SYS_GUID而言,性能上的影响在查询时间和创建时间上(在表格里要创建更多的块和索引以容纳数据)。对序列而言,性能上的影响在查询期间,在这个时候,SGA序列的缓冲区被用光。在缺省情况下,一个序列一次会缓冲20个值。如果数据库没有使用这些值就关闭了,它们就会被丢失。

SYS_GUID生成的值的另一个显著的不足之处是,管理这些值会变得困难得多。你必须(手动)输入它们或者通过脚本来填充它们,或者将它们作为Web参数来传递。

出于这些原因,将SYS_GUID作为一个主关键字不是一个很好主意,除非是在一个并行的环境里或者希望避免使用管理序列生成器的情况下。

posted @ 2004-11-25 14:23 35号房客 阅读(709) | 评论 (0)编辑

How can I make Yahoo! Mail my default email application?


How can I make Yahoo! Mail my default email application?


The Yahoo! Default Email Application is a small 60KB download that allows you to set Yahoo! Mail as your default email application in Microsoft Windows. For example, in Internet Explorer it lets you access your Yahoo! Mail account from any email link on a web page, as well as from the "File/Send" menu or the "Mail" button on the IE toolbar. It also allows you to send a file using Yahoo! Mail directly from Microsoft Word, Excel, and PowerPoint. It's perfect for Yahoo! Mail power users who would like easier access to their Yahoo! Mail accounts.

To install the program:

Go to this help page(http://help.yahoo.com/help/us/mail/ext/ext-11.html).
Check to make sure your system meets the requirements listed.
Click on "Continue." The program will automatically install on your hard drive and set Yahoo! Mail as your default email application.
After the download is complete, you'll have the opportunity to add links or shortcuts to Yahoo! Mail from your desktop and "Quick Launch" menu.
Once this application is installed, when you send files from Word, Excel, or PowerPoint, you'll be taken to the attachments interface in Yahoo! Mail. At the top of the attachments page, you'll be told where your file is temporarily stored. You can add the file to your message by clicking on "Browse" to find it in the location indicated and then attaching as usual.
If you want to switch your default mail application back to another email program, just click on "Tools" and then "Internet Options" in your Internet Explorer toolbar. Then click on the "Programs" tab, and use the pull-down menu to select the default email application you'd like. From there, click on "OK," and your changes will be saved.


The Yahoo! Default Email Application can be installed on a PC running Windows 9x, Windows Me, Windows NT, Windows 2000, or Windows XP. It works with Internet Explorer 4.0 and greater.

posted @ 2004-11-25 14:21 35号房客 阅读(833) | 评论 (0)编辑

Quick .Net File Download Security

Quick .Net File Download Security
http://www.wwwcoder.com/main/Default.aspx?tabid=68&mid=407&site=1795
In this article we will discuss providing a programmable method of securing files on for your ASP.Net applications. This code could come in handy where you have an application hosted on an ISP and you do not have access to a folder outside of your Web directory structure, and you are not able to change permissions on folder in the Web. This method does not require storing your file in a binary field in your database, thus reducing cost of having to buy database storage from your ISP, and with no impact on the network traffic between the database and web servers.

The Problem

On another project we have been talking about how we could allow a person upload a file to the Web application, and be able to secure the file so that someone couldn't type the file URL directly in the browser and be able to download the file.

Several methods were discussed of providing a secure file system for our application:

Database Storage

Storing the file in a database in a binary field, but this method could cost money for folks hosting with an ISP that charges for database storage, and it also impacts network traffic. Basically this solution entails storing the file in the database and attaching some security information in the database about the file; this could be user roles that are allowed to download the file. You can accomplish this by uploading the file to the database; when someone goes to access the file you would authenticate them, check the roles that can access the file, then check the user to see if they have permissions to access the file. Once you're done with the security checks create an ADO stream and send the file information to their client.

The database method meets the requirement of providing secure method of downloading files and prevents someone from being able to access the file directly via typing in the URL into the browser. But as mentioned there are several drawbacks to this method.

File Storage

Another method would be storing the file in a folder on the Web server. If the file were stored in the Web application directory structure you could secure it using NT ACLs. While this method works for an intranet where you have administrative access to the machine, it does not work well if you are hosting a site with an ISP. An ISP may not be able to provide you with the level of security you need for your application.

Another file storage method was storing the files in a folder outside of the Web application's directory structure and streaming the file to the browser. This would be accomplished much in the same way as the database solution, where you could store security information in a table, but the actual file resides on the Web server. You would do your security checks in your code and send the file to the user once they authenticated for access to the file. This method would accomplish restricting the file for downloading directly from typing in the URL of the file since the code is handling the file stream. Again the drawback to this method is you have to rely on an administrator to configure the folders that will reside outside of the Web directory structure.

Another method was to store the file within the directory structure and use the web.config file to restrict access to the directory in the following manner:

<location path="SecureDirectory">
   <system.web>     
      <authorization>
         <deny users="*" />
      </authorization>
     </system.web>
</location>

This method will secure any requests that are being processed by ASP.Net, the problem is it will not secure files that are not being processed by ASP.Net; for example, pdf, doc, xls, and other files you wish to secure. A way around this is to change the settings in IIS so all file extensions are processed by ASP.Net. Again, in the ISP case they may not want to do this because it can have some performance implications.

One Solution

So how do you provide access to files and ensure they cannot be accessed directly by typing in a URL? The following blocks of code will cover one method of doing this using a combination of all the methods described above. This can be done entirely via code.

First, select a location for storing your files. As in the example web.config file mentioned previously, we'll select the "SecureDirectory" folder off of the Web root. We will keep the web.config modification to restrict access to this folder by unauthorized groups. We then create a database table to store security information for our file.

FILE_NAME

ACCESS_ROLES

myfile.doc

admin;managers

This table will contain the names of the files that are uploaded to our secure directory and the security roles that can access the file. Notice the actual file is not stored in the database just the associated security information.

The File Upload Code

Now that you have your table defined to store security information for your file, we need to create methods for uploading and downloading the documents from the server. We will create a webform with a file browse dialog to browse our local system and upload it the server. In your Webform.aspx file add the following:

<INPUT id="cmdBrowse" type="file" runat="server" size="50" NAME="cmdBrowse">
<asp:LinkButton id="cmdUpload" runat="server" Cssclass="CommandButton">
 Upload File
</asp:LinkButton>

Then in our code behind page, Webform.aspx.vb, we need to handle the file upload. The following code will take the file that is being uploaded, save it into our secure directory as defined in the web.config file, and add the extension "resources" to the file so it will secure the file from a directly typed URL. You could use any extension like .vb, .acsx, .config, .resources, .resx or any file type that will be processed by the .Net handler.

Private Sub cmdUpload_Click(ByVal sender As System.Object, _
           ByVal e As System.EventArgs) Handles cmdUpload.Click
     SecureFileUpload()
End Sub
Public Sub SecureFileUpload()
   Dim strFileName As String
   Dim strFileNamePath As String
   strFileName = System.IO.Path.GetFileName(cmdBrowse.PostedFile.FileName)
   'now save the file as an resources file.
   strFileNamePath = Request.MapPath("SecureDirectory") & "\" & strFileName & ".resources"
   If File.Exists(strFileNamePath) Then
      File.Delete(strFileNamePath)
   End If
   cmdBrowse.PostedFile.SaveAs(strFileNamePath)
End Sub

So now if a person tries to go to the file directly by typing in the URL they will be greeted by a login prompt and an eventual 401.2 status message of "Access is denied"


Denied download from directly entering the file URL.

Downloading the File

So now that we have the file on our Web server and it can't be downloaded by browsing to the file URL, how are we supposed to get the file to the people who are supposed to get it?

First, you need to pass the file that you want to download and check it against your database to see if they have permissions on the file. If they have permissions for the file, then proceed with the download. You can write any security check you want, you may want to run a stored procedure to check to see if your user is a member of a certain role for your portal. Since the security mechanism will vary depending on the application, we will call a CheckSecurity method that returns either true or false depending on whether or not the person has access to the file as defined by the table earlier in this article.

If CheckSecurity(filename, userole) Then
   SecureFileDownload(filename)
Else
  'change the http response to access denied or some other error.
End If

After checking the permissions in the database, if the user has access to the file we then call the SecureFileDownload method which accepts the file path as the parameter, maps the file to the physical directory on the server, then sends the download to the client without the resources extension allowing them to download the file.:

Public Sub SecureFileDownload(ByVal inFile As String)
    Dim strFileNamePath As String
    strFileNamePath = Request.MapPath("SecureDirectory") & "\" & inFile
    Dim myFile As FileInfo = New FileInfo(strFileNamePath)
    Response.Clear()
    'now we send the file header minus the resources extension.
    Response.AddHeader("Content-Disposition", "attachment; filename=" & _
         Replace(myFile.Name, ".resources", ""))
    Response.AddHeader("Content-Length", myFile.Length.ToString())
    Response.ContentType = "application/octet-stream"
    Response.WriteFile(myFile.FullName)
    Response.End()
End Sub


Download dialog for the file.

The user will be presented with a download dialog and is now able to save the file to their local system.

As discussed there are several methods you can do to secure your file downloads, the method described in this article is ideally suited for those who do not have access to the administrative functions of the Web server.

posted @ 2004-11-25 14:19 35号房客 阅读(793) | 评论 (0)编辑

如何让win XP实现自动登陆

如何让win XP实现自动登陆


Windows XP是一个比较安全的操作系统,每次启动时都要求选择账户并输入密码,对于公用电脑,这样当然更安全,但是如果这台电脑是一个人用,也没有什么重要资料,每次都要选择帐户并输入密码实在太麻烦了,怎么样才能让
Windows XP 不用输入密码自动登录呢?


单击"开始/运行",输入"rundll32 netplwiz.dll,UsersRunDll",按回车键后弹出"用户帐户"窗口,看清楚,这可跟"控制面板"中打开的"用户账户"面板窗口不同哦!然后取消选定"要使用本机,用户必须输入用户名和密码"选项,单击确定,在弹出的对话框中输入你想让电脑每次自动登录的账户和密码即可。


事实上,在Windows 2000中也可以这样实现自动登录,不过它可以通过"控制面板"打开"用户账户"窗口,而在Windows XP中不行罢了。

 

posted @ 2004-11-25 14:18 35号房客 阅读(10309) | 评论 (11)编辑

关于yahoo邮箱如何开通POP access服务

from(http://jeyoshiki.yculblog.com/post-165043.html)

众所周知,yahoo邮箱是不提供pop access服务的,所以yahoo邮箱只能在线上登陆收取信件,而不能用outlook或foxmail等软件收取。

不过,yahoo的邮箱其实是有办法开通pop access服务的。你只要愿意接受偶尔的广告邮件,你就可以开通名为yahoo! delivers的功能。这个yahoo官方提供的服务,所以不必担心。它的服务有两个。
1是网上阅读邮件和 POP 功能(不仅可以使用浏览器访问 Yahoo! 电邮,并且,还可以通过 POP3 及电子邮件程序收取信件。例如Eudora, Outlook, 或Netscape Mail )
2是邮件转发功能。利用邮件转发功能, 您收到的Yahoo!电邮可以被自动转发到您在这里指定的电子邮件地址。

我们要的pop access功能就是它的服务1。

方法:
把下面整个的链接贴到IE地址栏里。(注意:整个都是一行) http://rd.yahoo.com/mail_us/options/?http://edit.my.yahoo.com/config/set_popfwd?.src=ym&.done=http://us.f93.mail.yahoo.c om/ym/Options?YY=22797

如果你事先没有登陆邮箱,那你会进入平时登陆yahoo的登陆界面。登陆后选"是",即激活yahoo! delivers功能,然后按着他的步骤,两步完成设置。

如果你事先已经登陆了yahoo邮箱了,那你就跳过登陆界面,直接进入激活设置。

至此,你的yahoo邮箱已经开通了pop access功能。然后你就可以在你的outlook,foxmail等软件收发yahoo邮件了。很棒,是不是?

yahoo邮件服务器设置如下:

接收邮件(POP3)服务器:pop.mail.yahoo.com.cn
发送邮件(SMTP)服务器:smtp.mail.yahoo.com.cn

posted @ 2004-11-25 13:54 35号房客 阅读(34427) | 评论 (146)编辑

Installing the FrontPage Hit Counter Web Bot


Installing the FrontPage Hit Counter Web Bot
1. Go to the FrontPage program root directory (usually C:\Program Files\Microsoft FrontPage. Under that, create a directory named bots. Then under the bots directory create a directory named fpcount. So you should have directories set up like the following:

 

C:\Program Files\Microsoft FrontPage\bots\fpcount

2. In the fpcount directory you just created copy the following files from the FrontPage CD.


fpcount.inf
fpcntclt.btl

 

which can be found in the cdrom:\FrontPg\fpsdk20\WebBot\fpcount\misc\ directory, and the files:

fpcntsrv.dll
fpcntclt.dll

 

which can be found in the cdrom:\FrontPg\fpsdk20\WebBot\fpcount\winbin\ directory.

3. Switch to Folder View.

 

4. The copy the fpcount.exe file (found in the cdrom:\FrontPg\fpsdk20\WebBot\fpcount\winbin\ directory) into the web's cgi-bin and make sure the cgi-bin is executable (right click on the folder in the FrontPage explorer and go to properties).

5. Then select tools--Recalculate Hyperlinks.


You now should be able to go into the FrontPage editor and select insert--webbot component--hit counter.


Other resource:
How to add the FrontPage97 WebBot Counter to your own FrontPage web.(http://www.homepages.dsu.edu/waldnerm/docs/fp97counter-client.htm)

posted @ 2004-11-25 13:49 35号房客 阅读(291) | 评论 (0)编辑

ORACLE的启动和关闭

Oracle数据库提供了几种不同的数据库启动和关闭方式,本文将详细介绍这些启动和关闭方式之间的区别以及它们各自不同的功能。


一、启动和关闭Oracle数据库


对于大多数Oracle
DBA来说,启动和关闭Oracle数据库最常用的方式就是在命令行方式下的Server
Manager。从Oracle 8i以后,系统将Server
Manager的所有功能都集中到了SQL*Plus中,也就是说从8i以后对于数据库的启动和关闭可以直接通过SQL*Plus来完成,而不再另外需要Server
Manager,但系统为了保持向下兼容,依旧保留了Server
Manager工具。另外也可通过图形用户工具(GUI)的Oracle
Enterprise
Manager来完成系统的启动和关闭,图形用户界面Instance
Manager非常简单,这里不再详述。


要启动和关闭数据库,必须要以具有Oracle
管理员权限的用户登陆,通常也就是以具有SYSDBA权限的用户登陆。一般我们常用INTERNAL用户来启动和关闭数据库(INTERNAL用户实际上是SYS用户以SYSDBA连接的同义词)。Oracle数据库的新版本将逐步淘汰INTERNAL这个内部用户,所以我们最好还是设置DBA用户具有SYSDBA权限。


二、数据库的启动(STARTUP)


启动一个数据库需要三个步骤:


  1、 创建一个Oracle实例(非安装阶段)


  2、 由实例安装数据库(安装阶段)


  3、 打开数据库(打开阶段)


在Startup命令中,可以通过不同的选项来控制数据库的不同启动步骤。


1、STARTUP NOMOUNT


NONOUNT选项仅仅创建一个Oracle实例。读取init.ora初始化参数文件、启动后台进程、初始化系统全局区(SGA)。Init.ora文件定义了实例的配置,包括内存结构的大小和启动后台进程的数量和类型等。实例名根据Oracle_SID设置,不一定要与打开的数据库名称相同。当实例打开后,系统将显示一个SGA内存结构和大小的列表,如下所示:


SQL> startup nomount
ORACLE 例程已经启动。
Total System Global Area 35431692 bytes
Fixed Size 70924 bytes
Variable Size 18505728 bytes
Database Buffers 16777216 bytes
Redo Buffers 77824 bytes


2、STARTUP MOUNT


该命令创建实例并且安装数据库,但没有打开数据库。Oracle系统读取控制文件中关于数据文件和重作日志文件的内容,但并不打开该文件。这种打开方式常在数据库维护操作中使用,如对数据文件的更名、改变重作日志以及打开归档方式等。在这种打开方式下,除了可以看到SGA系统列表以外,系统还会给出"数据库装载完毕"的提示。


3、STARTUP


该命令完成创建实例、安装实例和打开数据库的所有三个步骤。此时数据库使数据文件和重作日志文件在线,通常还会请求一个或者是多个回滚段。这时系统除了可以看到前面Startup
Mount方式下的所有提示外,还会给出一个"数据库已经打开"的提示。此时,数据库系统处于正常工作状态,可以接受用户请求。


如果采用STARTUP NOMOUNT或者是STARTUP
MOUNT的数据库打开命令方式,必须采用ALTER
DATABASE命令来执行打开数据库的操作。例如,如果你以STARTUP
NOMOUNT方式打开数据库,也就是说实例已经创建,但是数据库没有安装和打开。这是必须运行下面的两条命令,数据库才能正确启动。


ALTER DATABASE MOUNT;
ALTER DATABASE OPEN;


而如果以STARTUP
MOUNT方式启动数据库,只需要运行下面一条命令即可以打开数据库:


   ALTER DATABASE OPEN.


4、其他打开方式


除了前面介绍的三种数据库打开方式选项外,还有另外其他的一些选项。


(1) STARTUP RESTRICT


这种方式下,数据库将被成功打开,但仅仅允许一些特权用户(具有DBA角色的用户)才可以使用数据库。这种方式常用来对数据库进行维护,如数据的导入/导出操作时不希望有其他用户连接到数据库操作数据。


(2) STARTUP FORCE


该命令其实是强行关闭数据库(shutdown
abort)和启动数据库(startup)两条命令的一个综合。该命令仅在关闭数据库遇到问题不能关闭数据库时采用。


(3) ALTER DATABASE OPEN READ ONLY;


该命令在创建实例以及安装数据库后,以只读方式打开数据库。对于那些仅仅提供查询功能的产品数据库可以采用这种方式打开.


深刻理解Oracle数据库的启动和关闭


三、数据库的关闭(SHUTDOWN)


对于数据库的关闭,有四种不同的关闭选项,下面对其进行一一介绍。


1、SHUTDOWN NORMAL


这是数据库关闭SHUTDOWN命令的确省选项。也就是说如果你发出SHUTDOWN这样的命令,也即是SHUTDOWN
NORNAL的意思。


发出该命令后,任何新的连接都将再不允许连接到数据库。在数据库关闭之前,Oracle将等待目前连接的所有用户都从数据库中退出后才开始关闭数据库。采用这种方式关闭数据库,在下一次启动时不需要进行任何的实例恢复。但需要注意一点的是,采用这种方式,也许关闭一个数据库需要几天时间,也许更长。


2、SHUTDOWN IMMEDIATE


这是我们常用的一种关闭数据库的方式,想很快地关闭数据库,但又想让数据库干净的关闭,常采用这种方式。


当前正在被Oracle处理的SQL语句立即中断,系统中任何没有提交的事务全部回滚。如果系统中存在一个很长的未提交的事务,采用这种方式关闭数据库也需要一段时间(该事务回滚时间)。系统不等待连接到数据库的所有用户退出系统,强行回滚当前所有的活动事务,然后断开所有的连接用户。


3、SHUTDOWN TRANSACTIONAL


该选项仅在Oracle
8i后才可以使用。该命令常用来计划关闭数据库,它使当前连接到系统且正在活动的事务执行完毕,运行该命令后,任何新的连接和事务都是不允许的。在所有活动的事务完成后,数据库将和SHUTDOWN
IMMEDIATE同样的方式关闭数据库。


4、SHUTDOWN ABORT


这是关闭数据库的最后一招,也是在没有任何办法关闭数据库的情况下才不得不采用的方式,一般不要采用。如果下列情况出现时可以考虑采用这种方式关闭数据库。


1、
数据库处于一种非正常工作状态,不能用shutdown
normal或者shutdown immediate这样的命令关闭数据库;


2、 需要立即关闭数据库;


3、 在启动数据库实例时遇到问题;


所有正在运行的SQL语句都将立即中止。所有未提交的事务将不回滚。Oracle也不等待目前连接到数据库的用户退出系统。下一次启动数据库时需要实例恢复,因此,下一次启动可能比平时需要更多的时间。


表1可以清楚地看到上述四种不同关闭数据库的区别和联系。


  表1 Shutdown数据库不同方式对比表


关闭方式                      A   I  T   N
允许新的连接                  × ×  ×  ×
等待直到当前会话中止          × ×  ×  √
等待直到当前事务中止          × ×  √  √
强制CheckPoint,关闭所有文件 × √ √ √


 其中:A-Abort I-Immediate T-Transaction N-Nornal     conn / as
sysdba

 

posted @ 2004-11-25 13:45 35号房客 阅读(433) | 评论 (0)编辑

Install Tomcat As windows service

a)
%CATALINA_HOME%\bin\tomcat -install "Tomcat" "%JAVA_HOME%\jre\bin\server\jvm.dll" -Djava.class.path="%CATALINA_HOME%\bin\bootstrap.jar;%JAVA_HOME%\lib\tools.jar" -Dcatalina.home="%CATALINA_HOME%" -Xrs -start org.apache.catalina.startup.Bootstrap -params start -stop org.apache.catalina.startup.Bootstrap -params stop -out "%CATALINA_HOME%\logs\stderr.log"

 
b)
%CATALINA_HOME%\bin\tomcat.exe -uninstall -Tomcat

posted @ 2004-11-25 13:43 35号房客 阅读(375) | 评论 (0)编辑

用vb6读写INI文件的模块

Attribute VB_Name = "Module1"
Option Explicit

Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, _
    ByVal lpKeyName As Any, _
    ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long


Public Function ReadINI(ByVal Section As String, ByVal Key As String) As String
    Dim x As Long, Buff As String * 128, i As Integer
    x = GetPrivateProfileString(Section, Key, "", Buff, 128, App.Path + "TMPlayer.ini")
    i = InStr(Buff, Chr(0))
    ReadINI = Trim(Left(Buff, i - 1))
End Function
Public Function WriteINI(ByVal Section As String, ByVal Key As String) As String
    Dim x As Long, Buff As String * 128, i As Integer
    x = WritePrivateProfileString(Section, Key, "", Buff, 128, App.Path + "TMPlayer.ini")
    i = InStr(Buff, Chr(0))
    WriteINI = Trim(Left(Buff, i - 1))
End Function

posted @ 2004-10-12 14:13 35号房客 阅读(663) | 评论 (1)编辑

Twip&px

Twip」是一种和屏幕无关的单位,目的是为了让应用程序元素输出到不同设备时都能保持一致的计算方式。打印机的一个点,相当于20Twips,一英吋相当于 1440Twips, 一公分则相当于567 Twips ,也就是说,如果屏幕上某个对象的长度是1440 Twip的话,将会印出一英吋来。由于我们在屏幕上操作时会习惯用「像素」(也就是我们常说的屏幕分辨率),所以我们直接输入数字时必须再将「像素」换算成「Twip」。一个像素等于15Twips。如果希望窗体的高是「400」像素,宽是「300」像素,属性的设定值就是: Height=400×15=6000Width =300×15=4500

posted @ 2004-10-08 16:33 35号房客 阅读(509) | 评论 (1)编辑

我的pg上的上,sql-server-style的new_uuid

shell里面,建立语言:
[postgres@lacl-001 /root]$createlang -d lacl plpgsql
然后到psql里面创建一个函数new-uuid():
CREATE OR REPLACE FUNCTION new_uuid()
  RETURNS text AS
'
declare
vWork1 text;
vWork2 text;
vMac text;
begin
-- replace vMac with the mac of your own box
vMac=\'00:0D:56:FD:A0:DB\';
vWork1 := md5(vMAC || now());
vWork2 := SUBSTRING(vWork1, 1, 8) ||\'-\'|| SUBSTRING(vWork1,9,4) ||\'-\'|| SUBSTRING(vWork1,13,4) ||\'-\'|| SUBSTRING(vWork1,17,4) ||\'-\'|| SUBSTRING(vWork1,21,12);
RETURN cast(vWork2 as varchar(36));
end;
'
  LANGUAGE 'plpgsql' VOLATILE;

posted @ 2004-10-03 14:52 35号房客 阅读(292) | 评论 (0)编辑

可能你没有注意的Exception的属性

每次总是
catch(Exception ee)
{
    MesageBox.Show(ee.Message);
}

昨天晚上看书,发现了fcl里面很多Exception 的继承类,可以提供更多的一场相关信息。今天找了OleDbException ,巴适!

      
catch(System.Data.OleDb.OleDbException ee)
      
{
       
for (int j=0; j < ee.Errors.Count; j++)
       
{
        MessageBox.Show(
"Index #" + j + " " +
         
"Message: " + ee.Errors[j].Message + " " +
         
"Native: " + ee.Errors[j].NativeError.ToString() + " " +
         
"Source: " + ee.Errors[j].Source + " " +
         
"SQL: " + ee.Errors[j].SQLState + " ");
       }

      }


再比如System.ArgumentException.ParamName属性。呵呵,这样的东西还有很多。

posted @ 2004-09-30 21:14 35号房客 阅读(471) | 评论 (0)编辑

用c#获取本机mac(通过dll调用)

     摘要: usingSystem;usingSystem.Net;usingSystem.Runtime.InteropServices;publicenumNCBCONST{NCBNAMSZ=16,/**//*absolutelengthofanetname*/MAX_LANA=254,/**//*lana'sinrange0toMAX_LANAinclusive*/NCBENUM=0x37,/**//*...  阅读全文

posted @ 2004-09-28 11:08 35号房客 阅读(572) | 评论 (0)编辑

答谢cnblogs.com:散两个gmail邀请

需要的同志,请发email到ncowboy@gmail.com。内容包括:
cnblogs blog:http://www.cnblogs.com/张三/
first name:张 
last name:三

posted @ 2004-09-27 13:13 35号房客 阅读(270) | 评论 (0)编辑

使用WMI获取远程机器操作系统的详细信息

     摘要: 代码主题部分的OperatingSystem类,是使用工具(Management (WMI) Extensions for Visual Studio .NET 2003 Server Explorer http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=62d91a63-1253-4ea6-...  阅读全文

posted @ 2004-09-27 13:04 35号房客 阅读(874) | 评论 (3)编辑

NScript - A script host for C#/VB.NET/JScript.NET

Introduction

NScript is a tool similar to WScript except that it allows scripts to be written in .NET languages such as C#, VB.NET and JScript.NET. NScript automatically compiles the code into an assembly in memory and executes the assembly. The NScript setup application associates NScript with ".ncs" (for C# scripts), ".nvb" (for VB.NET scripts) and ".njs" (for JScript .NET scripts) file extensions. This enables any code written in these files to be executed directly by double clicking on these files in windows explorer. I wrote this tool when I needed to write a script for automating builds. A simple batch file was not sufficient for the task and I preferred to write code in C# as opposed to VBScript or JScript. This tool came in handy as I could modify the scripts easily and execute them by double clicking on the files in windows explorer.

Using NScript

  1. Download and unzip the setup
  2. Run the setup file NScript.msi. You need to have windows installer as well as the .NET framework installed on the machine before running the .msi file
  3. The setup automatically associates the file extensions ".ncs", ".nvb" and ".njs" with NScript.
  4. Write some code in C# like
    using System.Windows.Forms;
    
    class Test
    {
        static void Main(string[] args)
        {
            MessageBox.Show("Hello World!", "NScript");
        }
    };
  5. Save the file and give it an extension of .ncs

    You can execute the code in the file in any of the following ways:-

    1. Double click on the file in windows explorer in that case the script is launched using NScriptW
    2. At the command prompt type NScript MessageBox.ncs
    3. At the command prompt type NScriptw MessageBox.ncs
    4. You can execute code written in VB.NET or JScript.NET too. You need to save VB.NET files with the extension ".nvb" and JScript.NET files with extension ".njs"
  6. To cancel the execution when running in console mode press Ctrl+C or Ctrl+Break. When running under windows mode (i.e. NScriptW) an animating icon is shown in system tray. Double clicking on the icon cancels the execution.

The requirements for the code to be executed by NScript are:-

  1. The code should have a class defined.
  2. The class should have the Main method which takes single argument of type array of strings.
  3. You can refer to any assemblies listed in a file named NScript.nrf if it exists in the same directory as the NScript.Exe. Here is a sample content of NScript.nrf file
    System.Web.dll
    System.Web.RegularExpressions.dll
    System.Web.Services.dll
    System.Windows.Forms.Dll
    System.XML.dll
    
    It just has list of assembly names on each line.

How it Works?

The NScript solution has three projects:-

  1. NScript - a C# console application
  2. NScriptW - a C# windows application
  3. NScriptLib - a C# class library

NScript and NScriptW are very much similar to each other; the former can be used to run scripts that can output to console. NScript shows error messages in console where as NSCriptW shows error messages using message boxes. It is NScriptW which is associated with file extensions. Since there is lot of code that is shared by the two executables the common code is compiled in NScriptLib and both the executables refer to this class library.

The code behind NScript is pretty simple :-

  1. NScript creates an asynchronous delegate that does the compilation and execution asynchronously.
    CompileAndExecuteRoutine asyncDelegate = new 
        CompileAndExecuteRoutine(this.CompileAndExecute);
    
    IAsyncResult result = asyncDelegate.BeginInvoke(fileName, 
        newargs, this, null, null);
    
    //For a windows app a message loop and for a 
    // console app a simple wait
    ExecutionLoop(result);
    
    asyncDelegate.EndInvoke(result);
    
  2. The compilation and execution routine creates a separate AppDomain where it does the main compilation and execution. This is done because the user may require to cancel the execution of he script, in that case the AppDomain can simply be unloaded.
    //Create an AppDomain to compile and execute the code
    //This enables us to cancel the execution if needed
    executionDomain = AppDomain.CreateDomain("ExecutionDomain");
    
    IScriptManager manager = (IScriptManager)
        executionDomain.CreateInstanceFromAndUnwrap(
            typeof(BaseApp).Assembly.Location, 
            typeof(ScriptManager).FullName); 
    
    manager.CompileAndExecuteFile(file, args, this);
    

    IScriptManager interface is implemented by the type ScriptManager. Since any object has to be marshaled in order for it to be referenced from a separate AppDomain, we need the interface IScriptManager (as opposed to directly using the ScriptManager object). The ScriptManager type extends the MarshalByRefObject as it is marshaled by reference.

    public class ScriptManager : MarshalByRefObject, IScriptManager
    
  3. The main compilation and execution is carried out by the ScriptManager object's CompileAndExecute method. It used CodeDOM to carry out the compilation. It first figures out the CodeDomProvider to use based on the extension of the input script file
    //Currently only csharp scripting is supported
    CodeDomProvider provider;
    
    string extension = Path.GetExtension(file);
    
    switch(extension)
    {
    case ".cs":
    case ".ncs":
        provider = new Microsoft.CSharp.CSharpCodeProvider();
        break;
    case ".vb":
    case ".nvb":
        provider = new Microsoft.VisualBasic.VBCodeProvider();
        break;
    case ".njs":
    case ".js":
        provider = (CodeDomProvider)Activator.CreateInstance(
            "Microsoft.JScript", 
            "Microsoft.JScript.JScriptCodeProvider").Unwrap();
        break;
    default:
        throw new UnsupportedLanguageExecption(extension);
    }
    
  4. Once we have a CodeDomProvider we can compile the file into a temporary assembly using the ICodeCompiler interface
    System.CodeDom.Compiler.ICodeCompiler compiler = 
        provider.CreateCompiler();
    
    System.CodeDom.Compiler.CompilerParameters compilerparams = 
        new System.CodeDom.Compiler.CompilerParameters();
    
    compilerparams.GenerateInMemory = true;
    compilerparams.GenerateExecutable = true;
    
    System.CodeDom.Compiler.CompilerResults results = 
        compiler.CompileAssemblyFromFile(compilerparams, file);
    
  5. And finally the entry point method of the just compiled assembly is invoked.
    results.CompiledAssembly.EntryPoint.Invoke(
        null, BindingFlags.Static, null, new object[]{args}, null);
    

Conclusion

This is a very simple tool and I must confess that this is in no way an original idea. Don Box wrote a similar tool long time back but I could not locate it. As a result I decided to write my own. In future I hope to enhance it by allowing to compile and execute XML files similar to ".wsh" files. As usual any suggestions are welcome.

posted @ 2004-05-02 18:23 35号房客 阅读(955) | 评论 (2)编辑

如何在linux下进行adsl拨号

如何在linux下进行adsl拨号
cowboy
chenzizhao@hotmail.com

安装拨号软件
配置网卡
配置拨号软件
测试拨号
总结


安装拨号软件
本来很简单,老被人问起。我干脆写下来得了。首先,你必须安装相应的adsl拨号软件。平常用的rh中,带有pppoe这个rpm包。
我们通过
 rpm -qa|grep pppoe
这个命令的输出来确定系统中是否已经安装了pppoe这个包。rpm -qa是列出系统中已经安装的包。通过管道|将这个命令的输出,作为第二个命令的输入。grep pppoe是列出包含有pppoe的行。如果返回为空,则说明没有安装。如果安装了,会返回安装了pppoe的版本号。如果你还没有安装的话,通过下面的命令安装。
 rpm -ivh pppoe*

配置网卡


配置拨号软件
安装了拨号软件,接下来,就进行设置,告诉pppoe怎么拨号。启动设置,通过下面这个命令:
 adsl-setup
首先,你会看到提示,要求你输入帐号。


测试拨号

总结

posted @ 2004-04-20 08:22 35号房客 阅读(3534) | 评论 (1)编辑

Navigator Proxy Auto-Config File Format

http://wp.netscape.com/eng/mozilla/2.0/relnotes/demo/proxy-live.html

Navigator Proxy Auto-Config File Format

March 1996

(There are several examples and tips in the end of this document)



 






The proxy autoconfig file is written in JavaScript. The file must define the function:

        function FindProxyForURL(url, host)
        {
            ...
        }
which will be called by the Navigator in the following way for every URL that is retrieved by it:
        ret = FindProxyForURL(url, host);
where:
url
the full URL being accessed.
host
the hostname extracted from the URL. This is only for convenience, it is the exact same string as between :// and the first : or / after that. The port number is not included in this parameter. It can be extracted from the URL when necessary.
ret
(the return value) a string describing the configuration. The format of this string is defined below.

Saving the Auto-Config File
Setting the MIME Type

  1. You should save the JavaScript function to file with a .pac filename extension; for example:
            proxy.pac
    Note 1: You should save the JavaScript function by itself, not embed it in HTML.

    Note 2: The examples in the end of this document are complete, there is no additional syntax needed to save it into a file and use it (of course, the JavaScripts have to be edited to reflect your site's domain name and/or subnets).

  2. Next, you should configure your server to map the .pac filename extension to the MIME type:
            application/x-ns-proxy-autoconfig
    If using a Netscape server, edit the mime.types file in the config directory. If using Apache, CERN or NCSA servers, use the AddType directive.
     

Return Value Format

The JavaScript function returns a single string.

If the string is null, no proxies should be used.

The string can contain any number of the following building blocks, separated by a semicolon:

DIRECT
Connections should be made directly, without any proxies.
PROXY host:port
The specified proxy should be used.
SOCKS host:port
The specified SOCKS server should be used.
 


 
 

If there are multiple semicolon-separated settings, the left-most setting will be used, until the Navigator fails to establish the connection to the proxy. In that case the next value will be used, etc.

The Navigator will automatically retry a previously unresponsive proxy after 30 minutes, then after 1 hour from the previous try (always adding an extra 30 minutes).

If all proxies are down, and there was no DIRECT option specified, the Navigator will ask if proxies should be temporarily ignored, and direct connections attempted. The Navigator will ask if proxies should be retried after 20 minutes has passed (then the next time 40 minutes from the previous question, always adding 20 minutes).

Examples:

PROXY w3proxy.netscape.com:8080; PROXY mozilla.netscape.com:8081
Primary proxy is w3proxy:8080; if that goes down start using mozilla:8081 until the primary proxy comes up again.
PROXY w3proxy.netscape.com:8080; PROXY mozilla.netscape.com:8081; DIRECT
Same as above, but if both proxies go down, automatically start making direct connections. (In the first example above, Netscape will ask user confirmation about making direct connections; in this third case, there is no user intervention.)
PROXY w3proxy.netscape.com:8080; SOCKS socks:1080
Use SOCKS if the primary proxy goes down.
 


 
 


Predefined Functions and Environment for the JavaScript Function


isPlainHostName(host)

host
the hostname from the URL (excluding port number).
True iff there is no domain name in the hostname (no dots).

Examples:

isPlainHostName("www")
is true.
isPlainHostName("www.netscape.com")
is false.
 


 
 


dnsDomainIs(host, domain)

host
is the hostname from the URL.
domain
is the domain name to test the hostname against.
Returns true iff the domain of hostname matches.

Examples:

dnsDomainIs("www.netscape.com", ".netscape.com")
is true.
dnsDomainIs("www", ".netscape.com")
is false.
dnsDomainIs("www.mcom.com", ".netscape.com")
is false.
 


 
 


localHostOrDomainIs(host, hostdom)

host
the hostname from the URL.
hostdom
fully qualified hostname to match against.
Is true if the hostname matches exactly the specified hostname, or if there is no domain name part in the hostname, but the unqualified hostname matches.

Examples:

localHostOrDomainIs("www.netscape.com", "www.netscape.com")
is true (exact match).
localHostOrDomainIs("www", "www.netscape.com")
is true (hostname match, domain not specified).
localHostOrDomainIs("www.mcom.com", "www.netscape.com")
is false (domain name mismatch).
localHostOrDomainIs("home.netscape.com", "www.netscape.com")
is false (hostname mismatch).
 


 
 


isResolvable(host)

host
is the hostname from the URL.
Tries to resolve the hostname. Returns true if succeeds.

Examples:

isResolvable("www.netscape.com")
is true (unless DNS fails to resolve it due to a firewall or some other reason).
isResolvable("bogus.domain.foobar")
is false.
 


 
 


isInNet(host, pattern, mask)

host
a DNS hostname, or IP address. If a hostname is passed, it will be resoved into an IP address by this function.
pattern
an IP address pattern in the dot-separated format
mask
mask for the IP address pattern informing which parts of the IP address should be matched against. 0 means ignore, 255 means match.
True iff the IP address of the host matches the specified IP address pattern.

Pattern and mask specification is done the same way as for SOCKS configuration.

Examples:

isInNet(host, "198.95.249.79", "255.255.255.255")
is true iff the IP address of host matches exactly 198.95.249.79.
isInNet(host, "198.95.0.0", "255.255.0.0")
is true iff the IP address of the host matches 198.95.*.*.
 


 
 


dnsResolve(host)

host
hostname to resolve
Resolves the given DNS hostname into an IP address, and returns it in the dot separated format as a string.

Example:

dnsResolve("home.netscape.com")
returns the string "198.95.249.79".

myIpAddress()

Returns the IP address of the host that the Navigator is running on, as a string in the dot-separated integer format.

Example:

myIpAddress()
would return the string "198.95.249.79" if you were running the Navigator on that host.

dnsDomainLevels(host)

host
is the hostname from the URL.
Returns the number (integer) of DNS domain levels (number of dots) in the hostname.

Examples:

dnsDomainLevels("www")
returns 0.
dnsDomainLevels("www.netscape.com")
returns 2.
 


 
 


shExpMatch(str, shexp)

str
is any string to compare (e.g. the URL, or the hostname).
shexp
is a shell expression to compare against.
Returns true if the string matches the specified shell expression.

Actually, currently the patterns are shell expressions, not regular expressions.

Examples:

shExpMatch("http://home.netscape.com/people/ari/index.html", "*/ari/*")
is true.
shExpMatch("http://home.netscape.com/people/montulli/index.html", "*/ari/*")
is false.
 


 
 


weekdayRange(wd1, wd2, gmt)

wd1
and
wd2
are one of the weekday strings:
    SUN MON TUE WED THU FRI SAT
gmt
is either the string: GMT or is left out.
 


 
 

Only the first parameter is mandatory. Either the second, the third, or both may be left out.

If only one parameter is present, the function yeilds a true value on the weekday that the parameter represents. If the string "GMT" is specified as a second parameter, times are taken to be in GMT, otherwise in local timezone.

If both wd1 and wd1 are defined, the condition is true if the current weekday is in between those two weekdays. Bounds are inclusive. If the "GMT" parameter is specified, times are taken to be in GMT, otherwise the local timezone is used.

Examples:

weekdayRange("MON", "FRI")
true Monday trhough Friday (local timezone).
weekdayRange("MON", "FRI", "GMT")
same as above, but GMT timezone.
weekdayRange("SAT")
true on Saturdays local time.
weekdayRange("SAT", "GMT")
true on Saturdays GMT time.
weekdayRange("FRI", "MON")
true Friday through Monday (note, order does matter!).
 


 
 


dateRange(day)
dateRange(day1, day2)
dateRange(mon)
dateRange(month1, month2)
dateRange(year)
dateRange(year1, year2)
dateRange(day1, month1, day2, month2)
dateRange(month1, year1, month2, year2)
dateRange(day1, month1, year1, day2, month2, year2)
dateRange(day1, month1, year1, day2, month2, year2, gmt)

day
is the day of month between 1 and 31 (as an integer).
month
is one of the month strings:
    JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
year
is the full year number, for example 1995 (but not 95). Integer.
gmt
is either the string "GMT", which makes time comparison occur in GMT timezone; if left unspecified, times are taken to be in the local timezone.
 

Even though the above examples don't show, the "GMT" parameter can be specified in any of the 9 different call profiles, always as the last parameter.
 
 

If only a single value is specified (from each category: day, month, year), the function returns a true value only on days that match that specification. If both values are specified, the result is true between those times, including bounds.

Examples:

dateRange(1)
true on the first day of each month, local timezone.
dateRange(1, "GMT")
true on the first day of each month, GMT timezone.
dateRange(1, 15)
true on the first half of each month.
dateRange(24, "DEC")
true on 24th of December each year.
dateRange(24, "DEC", 1995)
true on 24th of December, 1995.
dateRange("JAN", "MAR")
true on the first quarter of the year.
dateRange(1, "JUN", 15, "AUG")
true from June 1st until August 15th, each year (including June 1st and August 15th).
dateRange(1, "JUN", 15, 1995, "AUG", 1995)
true from June 1st, 1995, until August 15th, same year.
dateRange("OCT", 1995, "MAR", 1996)
true from October 1995 until March 1996 (including the entire month of October 1995 and March 1996).
dateRange(1995)
true during the entire year 1995.
dateRange(1995, 1997)
true from beginning of year 1995 until the end of year 1997.
 


 
 


timeRange(hour)
timeRange(hour1, hour2)
timeRange(hour1, min1, hour2, min2)
timeRange(hour1, min1, sec1, hour2, min2, sec2)
timeRange(hour1, min1, sec1, hour2, min2, sec2, gmt)

hour
is the hour from 0 to 23. (0 is midnight, 23 is 11 pm.)
min
minutes from 0 to 59.
sec
seconds from 0 to 59.
gmt
either the string "GMT" for GMT timezone, or not specified, for local timezone. Again, even though the above list doesn't show it, this parameter may be present in each of the different parameter profiles, always as the last parameter.
 


 
 

True during (or between) the specified time(s).

Examples:

timerange(12)
true from noon to 1pm.
timerange(12, 13)
same as above.
timerange(12, "GMT")
true from noon to 1pm, in GMT timezone.
timerange(9, 17)
true from 9am to 5pm.
timerange(8, 30, 17, 00)
true from 8:30am to 5:00pm.
timerange(0, 0, 0, 0, 0, 30)
true between midnight and 30 seconds past midnight.
 


 
 


Example #1: Use proxy for everything except local hosts

This would work in Netscape's environment. All hosts which aren't fully qualified, or the ones that are in local domain, will be connected to directly. Everything else will go through w3proxy:8080. If the proxy goes down, connections become automatically direct.
    function FindProxyForURL(url, host)
    {
        if (isPlainHostName(host) ||
            dnsDomainIs(host, ".netscape.com"))
            return "DIRECT";
        else
            return "PROXY w3proxy.netscape.com:8080; DIRECT";
    }
Note: This is the simplest and most efficient autoconfig file for cases where there's only one proxy.


Example #1b: As above, but use proxy for local servers which are outside the firewall

If there are hosts (such as the main Web server) that belong to the local domain but are outside the firewall, and are only reachable through the proxy server, those exceptions can be handled using the localHostOrDomainIs() function:
    function FindProxyForURL(url, host)
    {
        if ((isPlainHostName(host) ||
             dnsDomainIs(host, ".netscape.com")) &&
            !localHostOrDomainIs(host, "www.netscape.com") &&
            !localHostOrDoaminIs(host, "merchant.netscape.com"))

            return "DIRECT";
        else
            return "PROXY w3proxy.netscape.com:8080; DIRECT";
    }
The above will use the proxy for everything else except local hosts in the netscape.com domain, with the further exception that hosts www.netscape.com and merchant.netscape.com will go through the proxy.

Note the order of the above exceptions for efficiency: localHostOrDomainIs() functions only get executed for URLs that are in local domain, not for every URL. Be careful to note the parentheses around the or expression before the and expression to achieve the abovementioned efficient behaviour.


Example #2: Use proxy only if cannot resolve host

This example would work in an environment where internal DNS is set up so that it can only resolve internal host names, and the goal is to use a proxy only for hosts which aren't resolvable:
    function FindProxyForURL(url, host)
    {
        if (isResolvable(host))
            return "DIRECT";
        else
            return "PROXY proxy.mydomain.com:8080";
    }
The above requires consulting the DNS every time; it can be grouped smartly with other rules so that DNS is consulted only if other rules do not yield a result:
    function FindProxyForURL(url, host)
    {
        if (isPlainHostName(host) ||
            dnsDomainIs(host, ".mydomain.com") ||
            isResolvable(host))
            return "DIRECT";
        else
            return "PROXY proxy.mydomain.com:8080";
    }

Example #3: Subnet based decisions

In this example all the hosts in a given subnet are connected to directly, others through the proxy.
    function FindProxyForURL(url, host)
    {
        if (isInNet(host, "198.95.0.0", "255.255.0.0"))
            return "DIRECT";
        else
            return "PROXY proxy.mydomain.com:8080";
    }
Again, use of DNS in the above can be minimized by adding redundant rules in the beginning:
    function FindProxyForURL(url, host)
    {
        if (isPlainHostName(host) ||
            dnsDomainIs(host, ".mydomain.com") ||
            isInNet(host, "198.95.0.0", "255.255.0.0"))
            return "DIRECT";
        else
            return "PROXY proxy.mydomain.com:8080";
    }

Example #4: Load balancing/routing based on URL patterns

This example is more sophisticated. There are four (4) proxy servers; one of them is a hot stand-by for all of the other ones, so if any of the remaining three goes down, the fourth one will take over.

Furthermore, the three remaining proxy servers share the load based on URL patterns, which makes their caching more effective (there is only one copy of any document on the three servers -- as opposed to one copy on each of them). The load is distributed like this:
Proxy Purpose
#1 .com domain
#2 .edu domain
#3 all other domains
#4 hot stand-by

All local accesses are desired to be direct. All proxy servers run on the port 8080 (they wouldn't need to). Note how strings can be concatenated by the + operator in JavaScript.

    function FindProxyForURL(url, host)
    {
        if (isPlainHostName(host) || dnsDomainIs(host, ".mydomain.com"))
            return "DIRECT";
        else if (shExpMatch(host, "*.com"))
            return "PROXY proxy1.mydomain.com:8080; " +
                   "PROXY proxy4.mydomain.com:8080";
        else if (shExpMatch(host, "*.edu"))
            return "PROXY proxy2.mydomain.com:8080; " +
                   "PROXY proxy4.mydomain.com:8080";
        else
            return "PROXY proxy3.mydomain.com:8080; " +
                   "PROXY proxy4.mydomain.com:8080";
    }

Example #5: Setting a proxy for a specific protocol

Most of the standard JavaScript functionality is available for use in the FindProxyForURL() function. As an example, to set different proxies based on the protocol, the substring() function can be used:
        function FindProxyForURL(url, host)
        {
            if (url.substring(0, 5) == "http:") {

                return "PROXY http-proxy.mydomain.com:8080";
            }
            else if (url.substring(0, 4) == "ftp:") {

                return "PROXY ftp-proxy.mydomain.com:8080";
            }
            else if (url.substring(0, 7) == "gopher:") {

                return "PROXY gopher-proxy.mydomain.com:8080";
            }
            else if (url.substring(0, 6) == "https:" ||
                     url.substring(0, 6) == "snews:") {

                return "PROXY security-proxy.mydomain.com:8080";
            }
            else {

                return "DIRECT";
            }
        }
Note: The same can be accomplished using the shExpMatch() function described earlier; for example:
        ...
        if (shExpMatch(url, "http:*")) {
            return "PROXY http-proxy.mydomain.com:8080;
        }
        ...

Tips

  • The autoconfig file can be output by a CGI script. This is useful e.g. when making the autoconfig file act differently based on the client IP address (the REMOTE_ADDR environment variable in CGI).
  • Use of isInNet(), isResolvable() and dnsResolve() functions should be carefully considered, as they require DNS server to be consulted (whereas all other autoconfig related functions are mere string matching functions). If a proxy is used, the proxy will perform its own DNS lookup which would double the impact on the DNS server. Most of the time these functions are not necessary to achieve the desired result.
     


     
     


March 1996


Help   |   Site Map   |   How to Get Netscape Products   |   Advertise With Us   |   Add Site   |   Custom Browser Program
Autos   |   Business   |   Computing & Internet   |   Entertainment   |   Family   |   Games   |   Health   |   Lifestyles   |   Local   |   Netscape   |   Netscape Open Directory   |   News   |   Personal Finance   |   Real Estate   |   Research & Learn   |  Shopping   |   Small Business   |   Sports   |   Travel
© 1999 Netscape, All Rights Reserved. Legal & Privacy Notices
This site powered by Netscape SuiteSpot servers.


 



posted @ 2004-02-22 01:22 35号房客 阅读(881) | 评论 (2)编辑