幻想指点江山,梦中激扬文字(飞天小肥猪的简单人生 Register | Login
浏览模式: 标准 | 列表2008年09月的文章

为windows的WEB服务器添加高性能的FTP组件

在windows服务器里面,如果我们要用FTP函数,速度应该是很慢的,而且效率不高,如果有大量文件需要上传,用自带的FTP函数,恐怕是要死人的吧。
windows服务器,windows哦,可以装N多软件的windows哦。虽然不建议在服务器上装上很多软件,但是也可以装一些FTP软件的嘛。这里以cuteftp举例。
cuteftp安装完毕后,会在软件目录里有一个Scripts目录,现在的版本不象很久以前的了,如今的版里只有一个Sample.vbs,记得几年前的cuteftp里面会有各种各样的vbs文件的。
闲话不多说,打开vbs文件,内容为:

ASP/Visual Basic代码
  1. 'This default template script is in VBScript. You can write scripts in your language of choice and save them with the proper extension, or use your an editor specific to that language.  
  2. 'See the TESDK help file for more details on how the scripting feature works and for information on each supported method and property.  
  3. 'You must have Windows Scripting Host installed for the COM enabled engine to work. Run the Transfer Engine once to register it (as a COM object) on the target system.  
  4. 'If you're having problems with running scripts while not logged in, or when trying to run them using MS scheduler, refer to our online knowledgebase for help (http://www.globalscape.com/support)  
  5. 'Look into c:\temp folder to observe local activity (for testing purposes) or right click on the Transfer Engine icon in the systray and select "show current transfers"  
  6. 'This sample script performs an anonymous login to ftp://ftp.globalscape.net  
  7.    'First declare a variable called Mysite. This will hold the reference to the TE COM object.  
  8.    Dim MySite  
  9.    'Create a connection object and assign it to the variable  
  10.    Set MySite = CreateObject("CuteFTPPro.TEConnection")  
  11.    ' Now set each property for the site connection   
  12.    ' You can omit this section to use the default values, but you should at least specify the Host  
  13.    'The default Protocol is FTP, however SFTP (SSH2), FTPS (SSL), HTTP, and HTTPS can also be used)  
  14.    MySite.Protocol = "FTP"  
  15.    MySite.Host = "ftp.globalscape.com"  
  16.    'following lines are optional since the default is anonymous if no login and password are defined  
  17.    MySite.Login = "anonymous"  
  18.    MySite.Password = "user@user.com"  
  19.    'if necessary, use the UseProxy method and ProxyInfo or SocksInfo properties to connect through a proxy server  
  20.    MySite.UseProxy = "BOTH"  
  21.    'now connect to the site (also called called implicitly when most remote methods are called)  
  22.    MySite.Connect  
  23.    'perform some logic to verify that the connection was made successfully  
  24.    If (Not Cbool(MySite.IsConnected)) Then    
  25.       MsgBox "Could not connect to: " & MySite.Host & "!"  
  26.       Quit(1)  
  27.    End If  
  28.    'The script will now check to see if the local folder c:\temp exists and will create it if necessary  
  29.    If (Not (MySite.LocalExists("c:\temp"))) Then  
  30.       MySite.CreateLocalFolder "c:\temp"  
  31.    End If  
  32.    'Change TE's local working folder to to c:\temp  
  33.    MySite.LocalFolder = "c:\temp"  
  34.    'Check for existence of remote folder "/pub/cuteftp"  
  35.    b = MySite.RemoteExists("/pub/cuteftp/")  
  36.    If (Not CBool(b)) Then  
  37.       'Verify existence of remote folder  
  38.       MsgBox "Remote folder not found!. Please make sure that the Pub folder exists on the remote site"  
  39.       Quit(1)  
  40.    End If  
  41.    'Now download the index file to the local destination folder  
  42.    MySite.Download "/pub/cuteftp/index.txt"  
  43.    'Complete.  Show the status of this transfer.  
  44.    MsgBox "Task done, final status is '" + MySite.Status + "'"  
  45.   MySite.Disconnect  
  46.   MySite.Close  
  47. 'End of sample script. You can save you script and then run it by either selecting it from the Tools > Run Script menu or by double clicking on the script file in Windows  

看到这样的文件,你应该知道如何调用一些FTP软件自带的方法了吧?现在,我们用PHP模拟一遍。。。。。
请看详细内容

» 阅读全文

Tags: ftp, com, windows, cuteftp, vbs

精通MYSQL数据库——连载七

今天我们继续学习一下MYSQL的数据类型
浮点型
从MYSQL3.23开始,FLOAT和DOUBLE类型就一直分别对应着IEEE标准所定义的单精度浮点数和双精度浮点数,绝大多数编程语言也都支持这两种数据类型。
当某个字段设置成这两种类型时,会要求按(m,d)这样的格式输入参数,其中m和上文介绍INT时所讲的m效果一样,仅仅在显示/打印结果时有一定的排版作用,而对数据的精确度没有影响。可是d这个参数就不一样了,d代表了小数点后面的数字个数,而且会按照d的大小来进行四舍五入,例如:1234.5678如果存储到FLOAT(8,3)这样的字段里,实际存放的是1234.568,最后一位会四舍五入。
存储FLOAT和DOUBLE时,如果超出了这两种类型的范围,将会被替换成该类型的最大可取值(一般由当前操作系统决定,我不知道MYSQL是怎么样。),可以使用SHOW WARNING来查看警告内容。
MYSQL对浮点数有一定的要求,即一定要符合通用计数法,小数点一定是“.”,而不能是“,”(因为有部分欧洲国家使用逗号作为小数点,我也是第一次听说,黑黑),MYSQL永远会以这种写法向客户返回查询结果,只有在非常大或非常小的数值,会采用科学计数法表示,如1.234E+017。如果想让浮点数表现形式变成其他样式,有两种方式:一是利用SQL查询中的FORMAT函数,二是用客户端程序中的FORMAT函数,例如php中就可以使用sprintf或者number_format等来改变显示效果

类型 含义
FLOAT(m,d) 单精度浮点数,8位精度,占4字节
DOUBLE(m,d) 双精度浮点数,16位精度,占8字节
REAL(m,d) DOUBLE的同义词



说到浮点数,当然要提定点数
正因为MYSQL在处理浮点数时,最后一位会被自动的四舍五入,而我们实际上并不需要这一位被四舍五入(比如在处理财务数据时),怎么办呢?定点数可以解决这个问题。
定点数(DECIMAL)数字是以字符串的形式来进行存储的,并且不被允许存储指数形式,每位数字占用一个字节,外加两个字节的开销,所以,占用了更多的空间,但可表示的数值范围却比较小。
在进行存储的时候,也有两个参数DECIMAL(p,s)这回,这两个参数都有作用了。p代表了数据的总位数(不含小数点),最大65,s代表了小数点后的数字位数,最大为30。比方说:DECIMAL(6,3)取值范围为-999.999~999.999,这是新的版本的表示方法。不知道我有没有记错,我记得在以前的版本里,DECIMAL(6,3),这个6并不是代表了总位数,而是小数点前的位数(可能是在4.0吧)。
在MYSQL内部,定点数是被保存为二进制格式的,把定点数从小数点开始分割,并为它们各自分配所占用的字节数(最初是以每4个字节进行划分,虽然每个字节可以容纳2位数字,但4个字节却可以容纳9位数字,超过4个字节后,如果有多出的数字就划分一个字节来进行存储,同样如果是9位数字,还是只占4个字节)。根据这个规定,我们可以认为DECIMAL(6,3)其实是和DECIMAL(18,9)占用了同样多的字节数(8个字节)。如此说来DECIMAL(19,9)实际就占用了9个字节。

类型 含义
DECIMAL(p,s) 定点数,以字符串形式保存,最长为65
NUMERIC,DEC 同上(应该没有记错吧)

参考:http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html

Tags: database, mysql, 连载

享受TP的DISPATCH功能

这篇日志被加密了,请输入密码后查看。

让手机迅速变成空号

有的时候你不想接别人的来电,但是又不想被别人知道你不想接,怎么办?一般来说有以下几种方法:
1、开机的时候,取电池,会有该用户暂时无法接通的提示
2、黑白名单,这个应该是最有效最安全的
3、输入**21*999999#,拨号,会让号码暂时变成空号,手机上会显示一个电话+一个箭头,恢复的时候按##21#再按拨号就恢复了。

Tags: 技巧, 空号, 拒绝来电

中秋快乐

这首词,梅艳芳也唱过,不过,斯人已远去,我等俗人无法再次回忘,值此中秋佳节,送上此词来缅怀先辈,同时也祝福所有的人都快乐。(顺便给自己放假一下,呵呵)

明月几时有
把酒问青天
不知天上宫
今夕是何年

我欲乘风归去
唯恐琼楼玉宇
高处不胜寒
起舞弄清影
何似在人间

转朱阁低绮户照无眠
不应有恨何事长向别时圆
人有悲欢离合月有阴晴圆缺
此事古难全
但愿人长久千里共婵娟

苏轼(苏轼是谁,我应该不用介绍了吧。。。再介绍就变成语文课了)

Tags: 中秋, 快乐, 苏轼, 梅艳芳