IIS经常需要添加的MIME备份
windows server 2016 的IIS10安装php manager和IIS URL Rewrite 2.0组件的方法
windows server 2016 出来了,第一时间在服务器上装上,然而原本支持组件有些无法安装了,win 2016是基于win 10来的,那么可以按照win 10的办法来。
php manager组件安装时提示“必须安装IIS7以上才可以安装”。那是不是真的就没法在新的IIS上安装了呢?显然不是的。自IIS7以来,微软的IIS更改并不大,架构一致,几乎所有IIS7能用的组件都能够在IIS7.7/8/8.5/10上安装。微软脑子秀逗,跳过了9,以为能解决版本识别的问题,没想到弄成10,还是出现了版本识别的问题,真是自己打自己的脸啊!
那么怎么办呢?改注册表!
打开regedit,找到:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters
右侧的 MajorVersion 是DWORD值,它的值十进制是10,把它改成9。然后运行php manager安装程序即可顺利安装上了!记得装完之后改回来。
php manager的最新下载地址是:http://phpmanager.codeplex.com/releases/view/69115
而IIS URL Rewrite 2.0更是奇怪,简体中文版的这个组件无法安装,同样也是检测版本不正常,而英文版却能正常安装。
64位英文版下载地址是:http://go.microsoft.com/fwlink/?LinkID=615137
简体中文版下载地址是:http://download.microsoft.com/download/4/E/7/4E7ECE9A-DF55-4F90-A354-B497072BDE0A/rewrite_x64_zh-CN.msi
但是面对一堆英文,有些人肯定也会头疼了,那么简体中文版到底能不能装上。
也能!还是改注册表,我通过分析MSI发现它会检测
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp
也是 MajorVersion 项,这个也是 dword 值 10(注意是十进制),把它改成9,结果顺利安装上了!记得装完之后改回来。
ASP和PHP一致的base64类(UTF-8、可以自定义修改码表)
因为项目关系,需要ASP跟PHP一致的base64类,gb2312的编码还好,到了utf-8就各种出错了,找了网上两个类来修改一下,测试可以用,并且修复了原来php那个类某些情况会乱码、无法在PHP5.2下运行的BUG
ASP版本:
<% class Base64_cls private sBASE_64_CHARACTERS Private Sub Class_Initialize() sBASE_64_CHARACTERS = String2Bytes("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/") end sub function Encode(byval str) Encode=EncodeBytes(String2Bytes(str)) end function function EncodeBytes(byval str) EncodeBytes=Bytes2String(Base64encode(str),"gb2312") end function function Decode(byval str) dim charset:charset = response.Charset if charset="" then charset = "utf-8" Decode=decodeAny(str,charset) end function function DecodeAny(byval str,byval charset) DecodeAny=Bytes2String(DecodeBytes(str),charset) end function function DecodeBytes(byval str) DecodeBytes=Base64decode(String2Bytes(str)) end function Function Base64encode(asContents) Dim lnPosition Dim lsResult Dim Char1 Dim Char2 Dim Char3 Dim Char4 Dim Byte1 Dim Byte2 Dim Byte3 Dim SaveBits1 Dim SaveBits2 Dim lsGroupBinary Dim lsGroup64 Dim m4,len1,len2 len1=Lenb(asContents) if len1<1 then Base64encode="" exit Function end if asContents = midb(asContents,1) m3=Len1 Mod 3 If M3 > 0 Then asContents = asContents & String(3-M3, chrb(0)) IF m3 > 0 THEN len1=len1+(3-m3) len2=len1-3 else len2=len1 end if lsResult = "" For lnPosition = 1 To len2 Step 3 lsGroup64 = "" lsGroupBinary = Midb(asContents, lnPosition, 3) Byte1 = Ascb(Midb(lsGroupBinary, 1, 1)): SaveBits1 = Byte1 And 3 Byte2 = Ascb(Midb(lsGroupBinary, 2, 1)): SaveBits2 = Byte2 And 15 Byte3 = Ascb(Midb(lsGroupBinary, 3, 1)) Char1 = Midb(sBASE_64_CHARACTERS, ((Byte1 And 252) \ 4) + 1, 1) Char2 = Midb(sBASE_64_CHARACTERS, (((Byte2 And 240) \ 16) Or (SaveBits1 * 16) And &HFF) + 1, 1) Char3 = Midb(sBASE_64_CHARACTERS, (((Byte3 And 192) \ 64) Or (SaveBits2 * 4) And &HFF) + 1, 1) Char4 = Midb(sBASE_64_CHARACTERS, (Byte3 And 63) + 1, 1) lsGroup64 = Char1 & Char2 & Char3 & Char4 lsResult = lsResult & lsGroup64 Next if M3 > 0 then lsGroup64 = "" lsGroupBinary = Midb(asContents, len2+1, 3) Byte1 = Ascb(Midb(lsGroupBinary, 1, 1)): SaveBits1 = Byte1 And 3 Byte2 = Ascb(Midb(lsGroupBinary, 2, 1)): SaveBits2 = Byte2 And 15 Byte3 = Ascb(Midb(lsGroupBinary, 3, 1)) Char1 = Midb(sBASE_64_CHARACTERS, ((Byte1 And 252) \ 4) + 1, 1) Char2 = Midb(sBASE_64_CHARACTERS, (((Byte2 And 240) \ 16) Or (SaveBits1 * 16) And &HFF) + 1, 1) Char3 = Midb(sBASE_64_CHARACTERS, (((Byte3 And 192) \ 64) Or (SaveBits2 * 4) And &HFF) + 1, 1) if M3=1 then lsGroup64 = Char1 & Char2 & ChrB(61) & ChrB(61) else lsGroup64 = Char1 & Char2 & Char3 & ChrB(61) end if lsResult = lsResult & lsGroup64 end if Base64encode = lsResult End Function Function Base64decode(asContents) Dim lsResult Dim lnPosition Dim lsGroup64, lsGroupBinary Dim Char1, Char2, Char3, Char4 Dim Byte1, Byte2, Byte3 Dim M4,len1,len2 len1= Lenb(asContents) M4 = len1 Mod 4 if len1 < 1 or M4 > 0 then Base64decode = "" exit Function end if if midb(asContents, len1, 1) = chrb(61) then m4=3 if midb(asContents, len1-1, 1) = chrb(61) then m4=2 if m4 = 0 then len2=len1 else len2=len1-4 end if For lnPosition = 1 To Len2 Step 4 lsGroupBinary = "" lsGroup64 = Midb(asContents, lnPosition, 4) Char1 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 1, 1)) - 1 Char2 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 2, 1)) - 1 Char3 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 3, 1)) - 1 Char4 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 4, 1)) - 1 Byte1 = Chrb(((Char2 And 48) \ 16) Or (Char1 * 4) And &HFF) Byte2 = lsGroupBinary & Chrb(((Char3 And 60) \ 4) Or (Char2 * 16) And &HFF) Byte3 = Chrb((((Char3 And 3) * 64) And &HFF) Or (Char4 And 63)) lsGroupBinary = Byte1 & Byte2 & Byte3 lsResult = lsResult & lsGroupBinary Next if M4 > 0 then lsGroupBinary = "" lsGroup64 = Midb(asContents, len2+1, m4) & chrB(65) if M4=2 then lsGroup64 = lsGroup64 & chrB(65) end if Char1 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 1, 1)) - 1 Char2 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 2, 1)) - 1 Char3 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 3, 1)) - 1 Char4 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 4, 1)) - 1 Byte1 = Chrb(((Char2 And 48) \ 16) Or (Char1 * 4) And &HFF) Byte2 = lsGroupBinary & Chrb(((Char3 And 60) \ 4) Or (Char2 * 16) And &HFF) Byte3 = Chrb((((Char3 And 3) * 64) And &HFF) Or (Char4 And 63)) if M4=2 then lsGroupBinary = Byte1 elseif M4=3 then lsGroupBinary = Byte1 & Byte2 end if lsResult = lsResult & lsGroupBinary end if Base64decode = lsResult End Function function String2Bytes(byval content) content = Server.URLEncode(content) content = replace(content,"+"," ") dim ret,i,c i=1 do while i<=len(content) c = mid(content,i,1) if c="%" then ret = ret & chrb(cbyte("&H" & mid(content,i+1,2))) i=i+3 else ret = ret & chrb(asc(c)) i=i+1 end if loop String2Bytes = ret end function public Function Bytes2String(ByVal byt,byval charset) If LenB(byt) = 0 Then Bytes2String = "" Exit Function End If Dim mystream, bstr Set mystream =Server.CreateObject("ADODB.Stream") mystream.Type = 2 mystream.Mode = 3 mystream.Open mystream.WriteText byt mystream.Position = 0 mystream.CharSet = charset mystream.Position = 2 bstr = mystream.ReadText() mystream.Close Set mystream = Nothing Bytes2String = bstr End Function end class dim str,str_e,str_d str="Base64是网络上最常见的用于传输8Bit字节代码的编码方式之一,大家可以查看RFC2045~RFC2049,上面有MIME的详细规范。Base64编码可用于在HTTP环境下传递较长的标识信息。例如,在Java Persistence系统Hibernate中,就采用了Base64来将一个较长的唯一标识符(一般为128-bit的UUID)编码为一个字符串,用作HTTP表单和HTTP GET URL中的参数。在其他应用程序中,也常常需要把二进制数据编码为适合放在URL(包括隐藏表单域)中的形式。此时,采用Base64编码具有不可读性,即所编码的数据不会被人用肉眼所直接看到。" set base64 = new Base64_cls str_e = base64.Encode(str) response.write str_e&"
" str_d = base64.decode(str_e) response.write str_d set base64 = nothing %>
PHP版本:
...asp与php常用函数对照表
asp(vbs)常用函数30个 | PHP类似函数 |
trim( ) | trim( ) |
replace( ) | str_replace( ) // str_ireplace( ) |
split( ) | explode( ) |
ubound( ) | count( ) |
isNull( ) | is_null( ) empty( ) 0,””,Null,False,空属性对象都将返回false |
isEmpty( ) | empty( ) 同上 isset( ) 是否已初始化 |
isNumeric( ) | is_numeric( ) |
instr( ) instrRev( ) | strpos( ) // stripos( ) strrpos( ) // strripos( ) |
mid( ) | substr( ) |
left( ) right( ) | 无对应函数 |
len( ) | strlen( ) |
cint( ) | intval( ) |
cstr( ) | strval( ) |
now( ) 当前日期+时间 date( ) 当前日期 year( ) month( ) day( ) | date (“Y-m-d H:i:s”) date(“Y-m-d”) date(“Y”) date(“m”) date(“d”) 详细请参见补充8中日期函数表 |
timer( ) | microtime( ) |
datediff( ) | 无对应内置函数,类似自定义函数如下 function DateDiff($date1,$date2,$unit="d"){ switch ($unit) { case 's': $dividend = 1; break; case 'i': $dividend = 60; break; case 'h': $dividend = 60*60; break; case 'd': $dividend = 60*60*24; break; case 'm': $dividend = 60*60*24*30; break; case 'y': $dividend = 60*60*24*365; break; default: $dividend = 60*60*24; } $time1 = strtotime($date1); $time2 = strtotime($date2); if ($time1 && $time2){ return ceil(($time1 - $time2) / $dividend); }else{ return false; } } 使用: |
ASP之微信支付(不借助其他语言)
进入微信商户后台设置密匙跟下载微信支付证书
...windows平台SVN迁移GIT的手记
把SVN服务器上auth配置里XXXX项目的用户配置复制出来,改成
SVN的用户名=git的用户名<git上的对应邮箱>
例如下面这样
svnuser1=gituser1<gituser1@email.com>
svnuser2=gituser2<gituser2@email.com>
svnuser3=gituser3<gituser3@email.com>
nginx相关的正则匹配
~ 匹配,区分大小写
~* 不区分大小写的匹配
!~ 不匹配
!~* 不匹配
^~ 常用于location 语法中,后边是一个字符串。它的意思是,在这个字符串匹配后停止进行正则表达式的匹配。
如: location ^~ /images/,你希望对/images/这个目录进行一些特别的操作,如增加expires头,防盗链等,但是你又想把除了这个目录的图片外的所有图片只进行增加expires头的操作,这个操作可能会用到另外一个location,例如:location ~* \.(gif|jpg|jpeg)$,这样,如果有请求/images/1.jpg,nginx如何决定去进行哪个location中的操作呢?结果取决于标识符^~,如果你这样写:location /images/,这样nginx会将1.jpg匹配到location ~* \.(gif|jpg|jpeg)$这个location中,这并不是你需要的结果,而增加了^~这个标识符后,它在匹配了/images/这个字符串后就停止搜索其它带正则的location。
= 表示精确的查找地址,如location = /它只会匹配uri为/的请求,如果请求为/index.html,将查找另外的location,而不会匹配这个,当然可以写两个location,location = /和location /,这样/index.html将匹配到后者,如果你的站点对/的请求量较大,可以使用这个方法来加快请求的响应速度。
@ 表示为一个location进行命名,即自定义一个location,这个location不能被外界所访问,只能用于Nginx产生的子请求,主要为error_page和try_files。
linux的端口转发到域名
linux安装nodejs支持
网上一堆教程教去编译源码的,如果linux功底不好就可能折腾出一大堆错误,所以还是直接安装省事点
sudo yum install nodejs npm
node -v
运行app.js
node app.js
让node在后台运行
npm install -g forever
...Win ser 的winsxs目录越来越大清理
安装这个http://www.microsoft.com/en-us/download/confirmation.aspx?id=42739 补丁
服务器管理器里安装 桌面体验 ,重启,开始-附件-系统工具-磁盘清理