Schema中无顺序的Element的写法

很郁闷的,在网上搜不到相关的内容。
很庆幸,Felix Validate给出很直观的错误提示。

试验了好久,终于写对了,记录一下。

这么写相当于

[转帖]10月20日未到,微软反盗xp黑屏补丁已被破解

声明下本人使用的是联想XPOEM正版系统

再次警告微软,想玩奉陪到底!敢动我的电脑,老子告你非法入侵私人领地!

今天看到了WGA的更新,到虚拟机里面换了个已经被封杀的VLK,然后安装更新进行了测试,如图。
另外,f1098老兄还带来了破解方法。废话不多说,如果你不幸安装了新版WGA可以通过以下方法将其“取消”:

开始-运行-输入REGEDIT回车,在左边栏中找到HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\NotifyWgaLogon项

  将整个WgaLogon项删除即可。以上为经过测试的最简便方法。

  这次的WGA与上次相比只增加了LegitCheckControl.dll,主要执行方式(通过WINLOGON加载)未变。显然微软此举可归为常规性不定期“恐吓”,此举也是对于盗版的无奈。

  WGA新版早已发布 盗版者屏幕确实可以变黑

  今天在微软上找到了那个即将大规模投放的kb905474补丁,其更新日期为9/23/2008,版本为1.8.0031.9。

  根据微软的描述:如果您的 Windows 副本未通过正版 Windows 验证,您将遇到下列症状:

  ? 登录通知

  登录时,在屏幕的右下角会看到以下消息:

  您可能是盗版软件的受害者。

  此 Windows 副本未通过正版 Windows 验证。

  此外,您还会看到以下消息:

  您可能是盗版软件的受害者。

  单击“立即解决”获取有关此问题的帮助。

  如果看到该消息,可使用以下两个选项:

  1 可以单击“立即解决”获取有关验证失败特定原因的更多信息并解决问题。 ? 如果选择不单击“立即解决”,稍等片刻后,将可以查看并单击“稍后解决”。如果选择此选项,在您登录后,系统会定期提醒您的 Windows 副本不是正版。接下来将说明这些通知。在通知区域还会出现一个图标,右键单击该图标可以查看一些选项,用于了解有关如何获得正版 Windows 的更多信息。

  2 通知区域

  如果 Windows 副本验证失败,您将在桌面的下部收到通知,表示您的 Windows 副本未能通过正版验证。您可以单击该通知或通知区域中的 WGA 图标,打开 Windows Genuine Advantage 验证失败网页。该网页可提供有关验证失败的细节,以及为确保操作系统为正版所需执行的步骤。

  3 永久桌面通知

  永久通知是悬浮在桌面右下角上的图像。如果您的 Windows XP 副本不是正版,永久通知将出现在任何活动窗口的下面,表示您的 Windows 副本未能通过正版验证。您可以对出现在永久通知下方的任意图标执行操作。但是,桌面上的对象无法将其隐藏。

  4 桌面背景更改

  如果 Windows 副本验证失败,桌面也会被设置为纯黑背景。您可以将背景重置为墙纸或另一背景颜色,但在您的 Windows 副本通过验证之前,每隔 60 分钟就会将桌面重置为纯黑色。

还有个简易的:

为了防止您家里的电脑到期出现黑屏,请做以下设置就可以做到不黑屏:
第一,“我的电脑”点右键,选“属性”,“自动更新”把有关自动更新的选项去掉。
第二,“我的电脑”点右键,选“管理”,点左边“服务和应用程序”旁的加号,展开,点“服务”。或者直接在“运行”中输入“Services.msc”打开服务设置窗口。在“服务”列表中,找到“AutomaticUpdates”这一项,双击,弹出的属性窗口中,“启动类型”设置为“已禁用”,确定即可。
如果是自动更新的XP请按上述情况更改系统

初等函数

太差劲了,去了上海一个月,回来连初等函数是什么都不知道了。
昨晚自习,在书上看到一切初等函数都是连续的,可是什么是初等函数?
于是回来上网搜了一下:
基本初等函数
我们最常用的有五种基本初等函数,分别是:指数函数、对数函数、幂函数、三角函数及反三角函数。
下面我们用表格来把它们总结一下:

函数名称 函数的记号 函数的图形 函数的性质
指数函数

a):不论x为何值,y总为正数;
b):当x=0时,y=1.

对数函数

a):其图形总位于y轴右侧,并过(1,0)点
b):当a>1时,在区间(0,1)的值为负;在区间(-,+∞)的值为正;在定义域内单调增.

幂函数

a为任意实数


这里只画出部分函数图形的一部分。

令a=m/n
a):当m为偶数n为奇数时,y是偶函数;
b):当m,n都是奇数时,y是奇函数;
c):当m奇n偶时,y在(-∞,0)无意义.

三角函数

(正弦函数)
这里只写出了正弦函数

a):正弦函数是以2π为周期的周期函数
b):正弦函数是奇函数且

反三角函数 (反正弦函数)
这里只写出了反正弦函数

a):由于此函数为多值函数,因此我们此函数值限制在[-π/2,π/2]上,并称其为反正弦函数的主值.

初等函数
由基本初等函数与常数经过有限次的有理运算及有限次的函数复合所产生并且能用一个解析式表出的函数称为初等函数.
例题:
是初等函数。

mod_rewrite: A Beginner’s Guide to URL Rewriting

So you’re a Web developer who has all the bells and whistles on your site, creates Web-based applications that are both beautiful and work well. But what about these issues?

Applications Must Be Safe

A user must not be able to harm your site in any way by modifying a URL that points to your applications. In order to ensure your site’s safe, check all the GET variables coming from your visitors (I think it’s trivial to mention that the POST variables are a must to examine).

For example, imagine we have a simple script that shows all the products in a category.o Generally, it’s called like this:

myapp.php?target=showproducts&categoryid=123

But what will this application do if ScriptKiddie(tm) comes and types this in his browser:

myapp.php?target=showproducts&categoryid=youarebeinghacked

Well, many of the sites I’ve seen will drop some error message complaining about use of the wrong SQL query, invalid MySQL resource ID, and so on… These sites are not secure. And can anyone guarantee that a site-to-be-finished-yesterday will have all the parameter verifications –even in a programmer group having only 2 or 3 people?

Applications Must Be Search-Engine Friendly

It’s not generally known, but many of the search engines will not index your site in depth if it contains links to dynamic pages like the one mentioned above. They simply take the “name” part of the URL (that’s everything before the question mark, which contains the parameters that are needed for most of the scripts to run correctly), and then try to fetch the contents of the page. To make it clear, here are some links from our fictitious page:

myapp.php?target=showproducts&categoryid=123
myapp.php?target=showproducts&categoryid=124
myapp.php?target=showproducts&categoryid=125

Unfortunately, there’s a big chance that some of the search engines will try to download the following page:

myapp.php

In most cases calling a script like this causes an error – but if not, I’m sure it will not show the proper contents the link was pointing to. Just try this search at google.com:

“you have an error in your sql syntax” .php -forum

There are both huge bugs and security in the scripts listed — again, these scripts are not search-engine friendly.

Applications must be user-friendly

If you application uses links like:

http://www.downloadsite.com?category=34769845698752354

then most of your visitors will find it difficult to get back to their favourite category (eg. Nettools/Messengers) every time they start from the main page of your site. Instead, they’d like to see URLs like this:

http://www.downloadsite.com/Nettools/Messengers

It’s even easier for the user to find (pick) the URL from the browsers’ drop-down list as they type into the Location field (though of course this only works if the user has visited that previously).

And what about you?

Now you have everything you need to answer the following questions:

  • Is your site really safe enough?
  • Can you protect your site from hackers?
  • Are your Websites search-engine compatible?
  • Are the URLs on your site ‘user friendly’ – are they easy to remember? …and would you like it to be? (everyone who answered ‘yes’ to all 4 questions: have a beer!)
An elegant solution

Okay, okay, I think you want to know the solution. Well, let’s get started. You’ll need:

  • everyone’s favourite Apache Webserver installed (v1.2 or later)
  • optionally, your favourite CGI scripts configured for Apache. Yes, I’ve said optionally, since what we’re going to do will happen right inside Apache and not PHP, or Perl, etc.
  • since (nearly) everything in Apache is controlled through its configuration files (httpd.conf, .htaccess, etc.), being familiar with these files might help you. You’ll also need to have write access to this file, and access to restart the Apache. I’d strongly recommend you do everything on a private testserver first, rather than on your own, or your company’s, production server!

Most of you will have read and/or heard about mod_rewrite — yes, it’s an Apache module, and it’s even installed by default! Go and check your modules directory (note that under *nix operating systems there’s a chance that your Apache was compiled with missing mod_rewrite, in which case, consult your sysadmin).

We’re going use this tiny module to achieve everything mentioned above. To use this module, first we have to enable it, since it’s initially disabled in the configuration file. Open the httpd.conf file and uncomment the following lines (remove the trailing #s):

#LoadModule rewrite_module modules/mod_rewrite.so
#AddModule mod_rewrite.c

The first line tells Apache to load the mod_rewrite module, while the second one enables the use of it. After you restart Apache, mod_rewrite should be enabled, but not yet running.

What is the mod_rewrite Solution, Exactly?

But what does it exactly do? Hey! Here comes the whole point of this article!

mod_rewrite catches URLs that meet specific conditions, and rewrites them as it was told to.

For example, you can have a non-existing

http://www.mysite.com/anything

URL that is rewritten to:

http://www.mysite.com/deep/stuff/very_complicated_url?text=

having_lots_of_extra_characters

Did you expect something more? Be patient…

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^/shortcut$ /complicated/and/way/too/long/url/here
</IfModule>

Of course this, too, should go into the httpd.conf file again, (you can even put it into a virtualhost context).

After you restart Apache (you’ll get used to it soon!) you can type this into your browser:

http://localhost/shortcut

If there’s a directory structure /complicated/and/way/too/long/url/here existing in your document root, you’re going to be “redirected” there, where you’ll see the contents of this directory (eg, the directory listing, index.html, whatever there is).

To understand mod_rewrite better, it’s important to know that this is not true redirection. “Classic” redirection is done with the Location: header of the HTTP protocol, and tells the browser itself to go to another URL. There are numerous ways to do this, for example, in PHP you could write:

<?
// this PHP file is located at http://localhost/shortcut/index.php
header
("Location: /complicated/and/way/too/long/url/here");
?>

This code shows the same page by sending a HTTP header back to the browser. That header tells the browser to move to another URL location instantly. But, what mod_rewrite does is totally different: it ‘tricks’ the browser, and serves the page as if it were really there – that’s why this is an URL rewriter and not a simple redirector (you can even verify the HTTP headers sent and received to understand the difference).

But it’s not just shortening paths that makes mod_rewrite the “Swiss Army Knife of URL manipulation”…

Rules

You’ve just seen how to specify a really simple RewriteRule. Now let’s take a closer look…

RewriteRule Pattern Substitution [Flag(s)]

RewriteRule is a simple instruction that tells mod_rewrite what to do. The magic is that you can use regular expressions in the Pattern and references in the Substitution strings. What do you think of the following rule?

RewriteRule /products/([0-9]+) /siteengine/products.php?id=$1

Now you can use the following syntax in your URLs:

http://localhost/products/123

After restarting Apache, you’ll find this is translated as:

http://localhost/siteengine/products.php?id=123

If you use only ‘fancy’ URLs in your scripts, there will be no way for your visitor to find out where your script resides (/siteengine in the example), what its name is (products.php), or what the name of the parameter to pass (productid) is! Do you like it? We’ve just completed two of our tasks, look!

  • Search-engine compatibility: there are no fancy characters in the URL, so the engines will explore your whole site
  • Security: ScriptKiddie(tm)-modified URLs will cause no error, as they’re verified with the regular expression first to be a number – URLs with no proper syntax can’t even reach the script itself.

Of course, you can create more complex RewriteRules. For example, here’s a set of rules I’m using on a site:

RewriteRule ^/products$ /content.php
RewriteRule ^/products/([0-9]+)$ /content.php?id=$1
RewriteRule
^/products/([0-9]+),([ad]*),([0-9]{0,3}),([0-9]*),([0-9]*$)
/marso/content.php?id=$1&sort=$2&order=$3&start=$4

Thanks to these rules I can use the followings links in the application:

  • Show an opening page that contains product categories: http://somesite.hu/products
  • Product listing, categoryid is 123, page 1 (as default), default order: http://somesite.hu/products/123 http://somesite.hu/products/123,,,,
  • Product listing, categoryid is 123, page 2, descending order by third field (d for descending, 3 for third field): http://somesite.hu/products/123,d,3,2

This is also an example of the use of multiple RewriteRules. When there’s a RegExp match, the proper substitution occurs, mod_rewrite stops running and Apache serves the page with the substituted URL. Should there be no match (after processing all the rules), a usual 404 page comes up. And of course you can also define one or more rules (eg. ^.*$ as last pattern) to specify which script(s) to run depending on the mistaken URL.

The third, optional part of RewriteRule is:

RewriteRule Pattern Substitution Flag(s)

With flags, you can send specific headers to the browser when the URL matches the pattern, such as:

  • forbidden‘ or ‘f‘ for 403 forbidden,
  • gone‘ or ‘g‘ for 410 gone,
  • you may also force redirection, or force a MIME-type.

You can even use the:

  • nocase‘ or ‘NC‘ flag to make the pattern case-insensitive
  • next/N‘ to loop back to the first rule (‘next round‘ — though this may result in an endless loop, be careful with it!)
  • skip=N/'S=N‘ to skip the following N rules

…and so on.

I hope you feel like I felt while playing around with this module for the first time!

Conditions

But that’s not all! Though RewriteRule gives you an opportunity to have professional URL rewriting, you can make it more customized using conditions.

The format of the conditions is simple:

RewriteCond Something_to_test Condition

Any RewriteCond condition affects the behaviour of the following RewriteRule, which is a little confusing, as RewriteCond won’t be evaluated until the following RewriteRule pattern matches the current URL.

It works like this: mod_rewrite takes all the RewriteRules and starts matching the current URL against each RewriteRule pattern. If there’s a RewriteRule pattern that matches the URL, mod_rewrite checks if there are existing conditions for this RewriteRule, and if the first one returns true. If it does, the proper substitution will occur, but if not, mod_rewrite looks for remaining conditions. When there are no more conditions, the subsequent RewriteRule is checked.

This way you can customize URL rewriting using conditions based on practically everything that’s known during a HTTP transfer in Apache — and a lot more! Basically you can use all of these variables in the Something_to_test string:

  • HTTP header variables: HTTP_USER_AGENT, HTTP_REFERER, HTTP_COOKIE, HTTP_FORWARDED, HTTP_HOST, HTTP_PROXY_CONNECTION, HTTP_ACCEPT
  • Connection & request variables: REMOTE_ADDR, REMOTE_HOST, REMOTE_USER, REMOTE_IDENT, REQUEST_METHOD, SCRIPT_FILENAME, PATH_INFO, QUERY_STRING, AUTH_TYPE
  • Server internal variables: DOCUMENT_ROOT, SERVER_ADMIN, SERVER_NAME, SERVER_ADDR, SERVER_PORT, SERVER_PROTOCOL, SERVER_SOFTWARE
  • System variables: TIME_YEAR, TIME_MON, TIME_DAY, TIME_HOUR, TIME_MIN, TIME_SEC, TIME_WDAY, TIME
  • mod_rewrite special values: API_VERSION, THE_REQUEST, REQUEST_URI, REQUEST_FILENAME, IS_SUBREQ

The condition can be a simple string or a standard regular expression, with additions like:

  • <, >, = simple comparison operators
  • -f if Something_to_test is a file
  • -d if Something_to_test is a directory

As you can see, these are more than enough to specify a condition like this one (taken from the mod_rewrite manual):

RewriteCond %{HTTP_USER_AGENT} ^Mozilla.*
RewriteRule ^/$ /homepage.max.html [L]

RewriteCond %{HTTP_USER_AGENT} ^Lynx.*
RewriteRule ^/$ /homepage.min.html [L]

RewriteRule ^/$ /homepage.std.html [L]

When a browser requests the index page, 3 things can happen:

  • browser with a Mozilla engine the browser will be served homepage.max.html
  • using Lynx (character-based browser) the homepage.min.html will open
  • if the browser’s name doesn’t contain ‘Mozilla’ nor ‘Lynx’, the standard homepage.std.html file will be sent

You can even disable users from accessing images from outside your server:

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://localhost/.*$ [OR,NC]
RewriteCond %{HTTP_REFERER} !^http://mysite.com/.*$ [OR,NC]
RewriteCond %{HTTP_REFERER} !^http://www.mysite.com/.*$ [OR,NC]
RewriteRule .*\.(gif|GIF|jpg|JPG)$ http://mysite/images/bad.gif [L,R]

But of course, there are endless possibilities, including IP- or time-dependant conditions, etc.

For Advanced Users

I mentioned user-friendliness in the introduction, and haven’t dealt with it. First, let’s imagine we’re having a huge download site that has the downloadable software separated into categories, each with a unique id (which is used in the SQL SELECTs). We use links like open.php?categoryid=23487678 to display the contents of a category.

To ensure that our URLs were easily memorized (eg. http://www.downloadsite.com/Nettools/Messengers) we could use:

RewriteRule ^/NetTools$ /test.php?target=3
RewriteRule ^/NetTools/Messengers$ /test.php?target=34

assuming the ID is 3 for the NetTools category and 34 for Messengers subcategory.

But our site is huge, as I’ve mentioned – who wants to hunt down all the IDs from the database, and then edit the config file by hand? No-one! Instead, we can use the mapping feature of mod_rewrite. Map allows us to provide a replacement-table – stored in a single text file — within a hash file (for fast lookups), or even served through an external program!

For better performance I’d generate a single text file using PHP, which contains the following:

NetTools            3
NetTools/Messengers 34
.
.
.
and so on.

The httpd.conf file would contain:

RewriteMap categories txt:/path/to/file/categoryids.txt
RewriteRule ^(.*)$ open.php?categoryid=${categories:$1|0}

These lines tell mod_rewrite to read the categoryids.txt file upon Apache startup, and provide the ID for the URL for open.php. The |0 means that categoryid will be 0 if there’s no matching key in the textfile.

You can also choose to serve the IDs on-the-fly via a script or other executable code. The program is started by Apache on server startup, and runs until shutdown. The program must have buffered I/O disabled, read from the stdin, and write results to stdout — it’s that simple!

With RewriteMap you can do a lot more, including:

  • load balancing through servers (using rnd:),
  • creation of a Webcluster that has an homogenous URL layout,
  • redirection to mirror sites without modifying your Web application,
  • denial of user access based on a hostlist,

and so on.

Tips, Tricks and Advice
  1. Before using mod_rewrite in a production server, I’d recommend setting up a testserver (or playground, whatever you prefer to call it).
  2. During development, you must avoid using ‘old-fashioned’ URLs in your application.
  3. There might still be need to verify data passed through the URL (passing non-existing — too large or small – IDs, for example, might be risky).
  4. Writing ‘intelligent’ RewriteRules saved me coding time and helped me write simpler code. I’m using error_reporting(E_ALL); everywhere (and I recommend it!), but I find it boring to do the following for the ten thousandths time:if (isset($_GET['id']) && (validNumber($_GET['id']))
    if (isset($_GET['todo']) && ($_GET['todo']=='deleteitem'))

    The following trick helped me to get rid of the extra isset() expression by providing all the needed parameters each time in the RewriteRules:

    RewriteRule ^/products/[0-9]+$ products.php?id=$1&todo=

    I know, I know it’s not the answer to the meaning of life — but it’s hard to show how nice and clear a solution this might provide in such a short example.

Finally…

That’s all for our ‘brief’ overview of mod_rewrite. After you’ve mastered the basics, you’ll find you can easily create your own rules. If you like the idea of URL rewriting, may want to play with mod_rewrite – some ideas follow (note that the underlying PHP code is not important in this case):

http://www.mysite.com/1/2/3/content.html
=> 1_2_3_content.html

http://www.mysite.com/1/2/3/content.html

=> content.php ? category=1

http://www.mysite.com/1/2/3/

=> content.php ? category=1 & subcat1 = 2 & subcat2 = 3

http://www.mysite.com/1/2/3/details

=> content.php ? category=1 & subcat1 = 2 & subcat2 = 3

http://www.mysite.com/bookshop/browse/bytitle

=> library.php ? target=listbooks & order = title

http://www.mysite.com/bookshop/browse/byauthor

=> library.php ? target=listbooks & order = author

http://www.mysite.com/bookshop/product/123

=> library.php ? target=showproduct & itemid=123

http://www.mysite.com/bookshop/helpdesk/2

=> library.php ? target=showhelp & page=2

http://www.mysite.com/bookshop/registration

=> library.php ? target=reg

Links

转自http://www.sitepoint.com/article/guide-url-rewriting/

JavaScript中获取元素的绝对位置

在一些应用中,可能会有需要知道某一个控件在页面中的位置,在网上比较容易找到下面这个解决方法。

在页面中有一个按钮:

在脚本中响应点击事件的是这个函数:

这个方法的实现相当精炼,意思就是先取得自己的相对位置,再叠加其最近的相对位置容器(offsetParent,它不一定是其父节点)的相对位置,直至顶层位置容器(一般就是body),从而得出该节点的相对位置。

不过,很快就发现这个函数也许并不够用,因为我在页面里有可能使用了一些CSS来使得本来平铺的画面变成一个滚动区域,例如设置了父节点的height为 某个值,并且其overflow设为auto或者scroll。这时,上面的方法因为没有计算其滚动偏移,所以所得的值不一定是元素当前的绝对位置,所以 我对上面的方法进行了一些小改动,实际上就是加入了对其滚动偏移量的计算。

稍微测试了一下,基本上在IE和FF中都能正常运转。
在运用方面,由于使用到往上遍历,如果节点树结构过于复杂,而且有不会有滚动出现的话,那么还是用第一个方法就足够了。

scrollLeft,scrollWidth,clientWidth,offsetWidth之完全详解

scrollHeight: 获取对象的滚动高度。
scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离
scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
scrollWidth:获取对象的滚动宽度
offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度
offsetLeft:获取对象相对于版面或由 offsetParent 属性指定的父坐标的计算左侧位置
offsetTop:获取对象相对于版面或由 offsetTop 属性指定的父坐标的计算顶端位置
event.clientX 相对文档的水平座标
event.clientY 相对文档的垂直座标

event.offsetX 相对容器的水平坐标
event.offsetY 相对容器的垂直坐标
document.documentElement.scrollTop 垂直方向滚动的值
event.clientX+document.documentElement.scrollTop 相对文档的水平座标+垂直方向滚动的量

以上主要指IE之中,FireFox差异如下:
IE6.0、FF1.06+:
clientWidth = width + padding
clientHeight = height + padding
offsetWidth = width + padding + border
offsetHeight = height + padding + border
IE5.0/5.5:
clientWidth = width – border
clientHeight = height – border
offsetWidth = width
offsetHeight = height
(需要提一下:CSS中的margin属性,与clientWidth、offsetWidth、clientHeight、offsetHeight均无关)

又跑了趟太平洋数码

昨天看ipod充电器的真伪对比照片,怎么看都感觉自己买到的充电器是假的。于是今天又去了趟太平洋电子城,最后证实是正品。顺便问了一下我买的ipod nano4国内上架时间,是9月30日,上架的,嘿嘿。
炫耀帖哈。