发布新日志

  • 用php实现文件安全下载

    2008-02-20 11:32:15Digest 5

    用php实现文件安全下载

    最 近在研究php实现文件下载的问题,按道理来说,一般的文件下载很简单,建立一个链接指向到目标文件就可以了,但是这样就直接暴露了文件所在路径,给盗链 者打开了大门,并且可能会有安全隐患,一般来说,要实现安全的文件下载,在php下一般是利用header和fread这么来做的:
    第一步
    假设你要下载的是一个torrent的文件,那么先建立一个动态php文件,用户点击下载文件的时候直接链接到这个php并传回与文件位置相关的参数以帮 助这个php能从数据库中取出文件所在的真实位置;这样做的另外一个好处是,可以通过这个php来对下载进行统计计数;这个过程并不难,所以就不写代码 了,主要是对数据库的查询,假设文件的真实位置是$fileAdd,文件名为$fileName;
    第二步
    得到文件所在的真实位置以后,有人会用header的location直接重定向到这个文件,但是这样仍然是不安全的,因为某些下载软件还是可以通过重定 向分析获得你的文件位置信息,因此需要用另外一种方法,就是php的文件处理API函数,这里主要是运用fread函数把文件直接吐给浏览器,让浏览器提 示用户下载,所有的这些处理都是在服务器端完成的,因此用户是不会知道文件具体位置信息的,具体代码如下:

    1. Header("content-type:application/octet-stream");
    2. Header("content-disposition:attatchment;filename:".$fileName.".torrent");
    3. if(file_exists($fileAdd) && $file=fopen($fileAdd,"r"))//判断文件是否存在并打开
    4. {
    5. fread($file,filesize($fileAdd));//读取文件内容并吐给浏览器
    6. fclose($file);
    7. }

    细心的朋友可能会发现为什么要在程序的前面加上一些header信息呢?
    因为,这些信息是用来告诉apache和浏览器下载文件的相关信息的,第一个content-type是告诉apache我的文件MIME类型是文件流格 式,如果你的apache配置里面把torrent的MIME类型设为了application/octet-stream(比如:add application/octet-stream .torrent),那么浏览器端就会知道这是一个torrent的文件并提示你下载,相反,如果apache没有做此类设置,浏览器将不会知道做如何处 理而将此文件直接以文本形式打开,这就是为什么有时候文件下载的时候浏览器上会出现乱码了;
    而第二个header发送的信息是用来告诉浏览器我的这个文件是可以当作附件被下载的,下载保存的名称为$fileName.torrent

  • 使用pgcc编译器编译mysql

    2007-09-22 19:52:30Digest 5

    许多新手往往把重新编译源代码看成是一种无可避免的灾祸,其实编译源代码还能对程序的最终性能起到显著的影响。编译过程可以用不同流水线上装配同样型号的 汽车比拟:第一条流水线由素质较低的工人操作,装配程序未能尽善尽美,零件装配误差较大;第二条流水线由高素质的技术工人操作,汽车装配程序合理,且利用 最好的工具保证产品的高质量。虽然两条流水线上装配出来的汽车外观一模一样,但两种汽车的性能表现却可能大不相同。对于编译器来说情况也完全相似,有些编 译器装配出来的程序要比其他编译器的更好。

       编译时考虑所有可用的选项也是极其重要的。很可能某些编译器的默认选项值不能符合要求,或者,为了满足应用的特定需求,我们需要指定一些特殊的编译选项。 正如MySQL文档所指出的,只要采用了更好的编译器或者使用更合理的编译选项,应用性能的提高程度可以达到10-30%。

       既然如此,编译时具体应该注意哪些问题才能让MySQL数据库运行得更快呢?

       ▲ 使用pgcc编译器

       如果系统使用的是奔腾处理器,那么pgcc(Pentium GCC)正是为这些系统下运行的程序提供的专用编译器。pgcc是gcc编译器(http://www.gnu.org/software/gcc/)的奔腾优化版,用pgcc编译MySQL代码可以让整体性能提高10%以上!关于pgcc的更多信息,请参见http://www.goof.com/pcg/。当然,如果系统使用的不是奔腾处理器,采用这种方法提高MySQL的运行速度就不合适了,因为正如其名字所示,pgcc是专门为奔腾系统提供的。

       ▲ 把mysqld编译成静态模式

       以不带共享库的形式编译mysqld同样可以提高性能。在配置行加入下面这个选项可以将mysqld编译成静态模式:


    % >./configure -with-mysqld-ldflags=-all-static [--其他配置选项]




       ▲ 配置示例

       下面的配置命令经常用于提高MySQL的性能:

    % >CFLAGS="-O6 -mpentiumpro -fomit-frame-pointer" CXX=gcc CXXFLAGS="-O6
    -mpentiumpro -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti"
    ./configure --prefix=/usr/local --enable-assembler --with-mysqld-ldflags=-all-static
    --disable-shared

       详细解释每个gcc选项的作用已经超出了本文的范围,请访问gcc的说明文档了解这些信息(http://gcc.gnu.org/)。注意不要拘泥于这个例子,请在命令行执行man gcc仔细了解每一个gcc选项的含义。

    正确的编译方法固然重要,但它只是提高MySQL服务器性能工作的一部分。MySQL服务器的许多参数会影响服务器的性能表现,而且我们可以把这些参数保存到配置文件,使得每次MySQL服务器启动时这些参数都自动发挥作用。这个配置文件就是my.cnf。

        MySQL服务器提供了my.cnf文件的几个示例,它们可以在/usr/local/mysql/share/mysql/目录下找到,名字分别为my -small.cnf、my-medium.cnf、my-large.cnf以及my-huge.cnf。文件名字中关于规模的说明描述了该配置文件适 用的系统类型。例如,如果运行MySQL服务器的系统内存不多,而且MySQL只是偶尔使用,那么使用my-small.cnf配置文件最为理想,这个配 置文件告诉mysqld daemon使用最少的系统资源。反之,如果MySQL服务器用于支持一个大规模的在线商场,系统拥有2G的内存,那么使用mysql-huge.cnf 最为合适。

       要使用上述示例配置文件,我们应该先复制一个最适合要求的配置文件,并把它命名为my.cnf。这个复制得到的配置文件可以按照如下三种方式使用:

    全局:把这个my.cnf文件复制到服务器的/etc目录,此时文件中所定义的参数将全局有效,即对该服务器上运行的所有MySQL数据库服务器都有效。

    局部:把这个my.cnf文件复制到[MYSQL-INSTALL-DIR]/var/将使该文件只对指定的服务器有效,其中[MYSQL-INSTALL-DIR]表示安装MySQL的目录。

    用户:最后,我们还可以把该文件的作用范围局限到指定的用户,这只需把my.cnf文件复制到用户的根目录即可。

        那么,如何设置my.cnf文件中的参数呢?或者进一步说,哪些参数是我们可以设置的呢?所有这些参数都对MySQL服务器有着全局性的影响,但同时每一 个参数都和MySQL的特定部分关系较为密切。例如,max_connections参数属于mysqld一类。那么,如何才能得知这一点呢?这只需执行 如下命令:

    % >/usr/local/mysql/libexec/mysqld --help

       该命令将显示出和mysqld有关的各种选项和参数。要寻找这些参数非常方便,因为这些参数都在“Possible variables for option --set-variable (-O) are”这行内容的后面。找到这些参数之后,我们就可以在my.cnf文件中按照如下方式设置所有这些参数:

    set-variable = max_connections=100

      这行代码的效果是:同时连接MySQL服务器的最大连接数量限制为100。不要忘了在my.cnf文件[mysqld]小节加上一个set-variable指令,具体请参见配置文件中的示例。
  • MySQL5解压缩版windows下安装配置应用总结

    2007-09-13 14:56:59Digest 4

    MySQL5解压缩版windows下安装配置应用总结    CSDN Blog推出文章指数概念,文章指数是对Blog文章综合评分后推算出的,综合评分项分别是该文章的点击量,回复次数,被网摘收录数量,文章长度和文章类型;满分100,每月更新一次。
    说明:本文针对mysql-noinstall版本,也就是解压缩版的安装配置应用做了个总结,这些操作都是平时很常用的操作。文章中不对mysql的可执行文件安装版做介绍了,可执行安装版有很多的弊端,我也不一一说了。总之,我喜欢绿色环保的,包括eclipse、tomcat、jboss、 apache也是,即使操作系统重装了,这些软件也不需要重装,可谓一劳永逸!
     
    环境:
    Windows 2000/XP/2003
    mysql-noinstall-5.0.37-win32.zip
     
    一、下载MySQL

    http://www.mysql.com/downloads
     
    二、安装过程
     
    1、解压缩mysql-noinstall-5.0.37-win32.zip到一个目录,加入解压缩到E:\myserver目录。
     
    2、编写mysql的运行配置文件my.ini
    my.ini
    -----------------------------
    [WinMySQLAdmin]
    # 指定mysql服务启动启动的文件
    Server=E:\\myserver\\mysql-5.0.37-win32\\bin\\mysqld-nt.exe
     
    [mysqld]
    # 设置mysql的安装目录
    basedir=E:\\myserver\\mysql-5.0.37-win32
    # 设置mysql数据库的数据的存放目录,必须是data,或者是\\xxx\data
    datadir=E:\\myserver\\mysql-5.0.37-win32\\data
    # 设置mysql服务器的字符集
    default-character-set=gbk
     
    [client]
    # 设置mysql客户端的字符集
    default-character-set=gbk
    -----------------------------
     
    3、安装mysql服务
    从MS-DOS窗口进入目录E:\myserver\mysql-5.0.37-win32\bin,运行如下命令:
    mysqld --install mysql5 --defaults-file= E:\myserver\mysql-5.0.37-win32\my.ini
     
    4、启动mysql数据库
    还在上面的命令窗口里面,输入命令:net start mysql5
    这样就启动了mysql服务。
     
    5、(本地)登录mysql数据库
    还在上面的命令窗口里面,输入命令:mysql -u root -p
    回车后提示输入密码。
    mysql解压缩版初次安装管理员root的密码为空,因此直接再回车一次就登入mysql数据库了。
     
    如果你不是初次登录mysql,你还拥有网络地址的用户,那么你可以用如下命令登录到mysql服务器,这个mysql服务器也许在远方,也许在本地。这种登录方式叫“远程登录”,命令如下:
    mysql -h 192.168.3.143 -u root -p
    mysql -h 192.168.3.143 -u root -pleizhimin
     
    -h是指定登录ip,-u指定用户,-p指定密码,-p后如果什么都不写,那么接下来会提示输入密码,-p后也可以直接写上密码,这样就不再需要输入密码了。
     
    6、操作数据库和表
    登录mysql数据库后,就可以执行指定操作数据库,用命令:use 数据库名
    指定了操作的数据库对象后,就可以操作数据库中的表了,操作方法当然是SQL命令了,呵呵。
     
    7、更改mysql数据库管理员root的密码
    mysql数据库中默认有个mysql数据库,这个是mysql系统的数据库,用来保存数据库用户、权限等等很多信息。要更改密码,就要操作mysql数据库的user表。
    现在mysql的root用户密码还为空,很不安全的,假设要更改密码为“leizhimin”。
     
    还在上面的命令窗口里面,执行如下命令:
    use mysql;
    grant all on *.* to root@'%' identified by 'leizhimin' with grant option;
    commit;
    这段命令的含义是,添加一个root用户,拥有所有的权限,密码为“leizhimin”,并且这个用户不但可以本地访问,也可以通过网络访问。强调这个原因是mysql系统自带的的那个root用户只能从本地访问,它@字符后面的标识是localhost。具体可以查看mysql数据的uer表看看,这样以来,就有两个root用户了,一个是系统原来的,一个新建的,为了管理的方便,就将mysql自带root删除,保留刚创建的这个root用户,原因是这个用户可以通过网络访问mysql。
     
    然后,删除用户的命令:
    user mysql;
    delete from user where user='root' and host='localhost';
    commit;
     
    其实上面的方法是授权命令,在授权的同时创建了数据库用户。mysql也有单独的修改用户密码的方法,下面看看如何操作。
    首先,先建立一个用户lavasoft,密码为:123456
    grant all on *.* to lavasoft@'localhost' identified by '123456' with grant  option;
     
    接下来就修改这个用户的密码为:leizhimin
    update user set password = password('leizhimin') where user = 'lavasoft' and host='localhost';
    flush privileges;
     
    说明一点,最好用grant的方式创建mysql用户,尤其对mysql DBA来说,创建用户的同时要指定用户权限,养成好习惯很重要的。
     
    这个修改方法实际上用的是mysql函数来进行的,还有更多的方法,我就不一一介绍了。
    还要注意一点就是在修改密码等操作的时候,mysql不允许为表指定别名,但是初次在外却没有这个限制。

    8、创建数据库
    实际上mysql数据库中除了mysql数据库外,还有一个空的数据库test,供用户测试使用。
    现在继续创建一个数据库testdb,并执行一系列sql语句看看mysql数据库的基本操作。
     
    创建数据库testdb:
    create database testdb;
     
    预防性创建数据库:
    create database if not testdb
     
    创建表:
    use testdb;
    create table table1(
    username varchar(12),
    password varchar(20));
     
    预防性创建表aaa:
    create table if not exists aaa(ss varchar(20));
     
    查看表结构:
    describe table1;
     
    插入数据到表table1:
    insert into table1(username,password) values
    ('leizhimin','lavasoft'),
    ('hellokitty','hahhahah');
    commit;
     
    查询表table1:
    select * from table1;
     
    更改数据:
    update table1 set password='hehe' where username='hellokitty';
    commit;
     
    删除数据:
    delete from  table1 where username='hellokitty';
    commit;
     
    给表添加一列:
    alter table table1 add column(
      sex varchar(2) comment '性别',
      age date not null comment '年龄'
    );
    commit;
     
    从查询创建一个表table1:
    create table tmp as
    select * from table1;
     
    删除表table1:
    drop table if exists table1;
    drop table if exists tmp;
     
    9、备份数据库testdb
    mysqldump -h 192.168.3.143 -u root -pleizhimin -x --default-character-set=gbk >C:\testdb.sql
     
    10、删除数据库testdb
    drop database testdb;
     
    11、恢复testdb数据库
    首先先建立testdb数据库,然后用下面命令进行本地恢复:
    mysql -u root -pleizhimin testdb <C:\testdb.sql
     
    12、删除mysql服务
    假如你厌倦mysql了,你需要卸载,那么你只需要这么做
     
    停止mysql服务
    net stop mysql5
     
    删除mysql服务
    sc delete mysql5

    然后删除msyql的安装文件夹,不留任何痕迹。
     

    Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1752641
  • MySQL5解压缩版windows下安装配置应用总结

    2007-09-13 14:56:59Digest 5

    MySQL5解压缩版windows下安装配置应用总结  
    说 明:本文针对mysql-noinstall版本,也就是解压缩版的安装配置应用做了个总结,这些操作都是平时很常用的操作。文章中不对mysql的可执 行文件安装版做介绍了,可执行安装版有很多的弊端,我也不一一说了。总之,我喜欢绿色环保的,包括eclipse、tomcat、jboss、 apache也是,即使操作系统重装了,这些软件也不需要重装,可谓一劳永逸!
     
    环境:
    Windows 2000/XP/2003
    mysql-noinstall-5.0.37-win32.zip
     
    一、下载MySQL
     
    二、安装过程
     
    1、解压缩mysql-noinstall-5.0.37-win32.zip到一个目录,加入解压缩到E:\myserver目录。
     
    2、编写mysql的运行配置文件my.ini
    my.ini
    -----------------------------
    [WinMySQLAdmin]
    # 指定mysql服务启动启动的文件
    Server=E:\\myserver\\mysql-5.0.37-win32\\bin\\mysqld-nt.exe
     
    [mysqld]
    # 设置mysql的安装目录
    basedir=E:\\myserver\\mysql-5.0.37-win32
    # 设置mysql数据库的数据的存放目录,必须是data,或者是
    \\xxx\data
    datadir=E:\\myserver\\mysql-5.0.37-win32\\data
    # 设置mysql服务器的字符集
    default-character-set=gbk
     
    [client]
    # 设置mysql客户端的字符集
    default-character-set=gbk
    -----------------------------
     
    3、安装mysql服务
    从MS-DOS窗口进入目录E:\myserver\mysql-5.0.37-win32\bin,运行如下命令:
    mysqld --install mysql5 --defaults-file= E:\myserver\mysql-5.0.37-win32\my.ini
     
    4、启动mysql数据库
    还在上面的命令窗口里面,输入命令:net start mysql5
    这样就启动了mysql服务。
     
    5、(本地)登录mysql数据库
    还在上面的命令窗口里面,输入命令:mysql -u root -p
    回车后提示输入密码。
    mysql解压缩版初次安装管理员root的密码为空,因此直接再回车一次就登入mysql数据库了。
     
    如果你不是初次登录mysql,你还拥有网络地址的用户,那么你可以用如下命令登录到mysql服务器,这个mysql服务器也许在远方,也许在本地。这种登录方式叫“远程登录”,命令如下:
    mysql -h 192.168.3.143 -u root -p
    mysql -h 192.168.3.143 -u root -pleizhimin
     
    -h是指定登录ip,-u指定用户,-p指定密码,-p后如果什么都不写,那么接下来会提示输入密码,-p后也可以直接写上密码,这样就不再需要输入密码了。
     
    6、操作数据库和表
    登录mysql数据库后,就可以执行指定操作数据库,用命令:use 数据库名
    指定了操作的数据库对象后,就可以操作数据库中的表了,操作方法当然是SQL命令了,呵呵。
     
    7、更改mysql数据库管理员root的密码
    mysql数据库中默认有个mysql数据库,这个是mysql系统的数据库,用来保存数据库用户、权限等等很多信息。要更改密码,就要操作mysql数据库的user表。
    现在mysql的root用户密码还为空,很不安全的,假设要更改密码为“leizhimin”。
     
    还在上面的命令窗口里面,执行如下命令:
    use mysql;
    grant all on *.* to root@'%' identified by 'leizhimin' with grant option;
    commit;
    这 段命令的含义是,添加一个root用户,拥有所有的权限,密码为“leizhimin”,并且这个用户不但可以本地访问,也可以通过网络访问。强调这个原 因是mysql系统自带的的那个root用户只能从本地访问,它@字符后面的标识是localhost。具体可以查看mysql数据的uer表看看,这样 以来,就有两个root用户了,一个是系统原来的,一个新建的,为了管理的方便,就将mysql自带root删除,保留刚创建的这个root用户,原因是 这个用户可以通过网络访问mysql。
     
    然后,删除用户的命令:
    user mysql;
    delete from user where user='root' and host='localhost';
    commit;
     
    其实上面的方法是授权命令,在授权的同时创建了数据库用户。mysql也有单独的修改用户密码的方法,下面看看如何操作。
    首先,先建立一个用户lavasoft,密码为:123456
    grant all on *.* to lavasoft@'localhost' identified by '123456' with grant  option;
     
    接下来就修改这个用户的密码为:leizhimin
    update user set password = password('leizhimin') where user = 'lavasoft' and host='localhost';
    flush privileges;
     
    说明一点,最好用grant的方式创建mysql用户,尤其对mysql DBA来说,创建用户的同时要指定用户权限,养成好习惯很重要的。
     
    这个修改方法实际上用的是mysql函数来进行的,还有更多的方法,我就不一一介绍了。
    还要注意一点就是在修改密码等操作的时候,mysql不允许为表指定别名,但是初次在外却没有这个限制。

    8、创建数据库
    实际上mysql数据库中除了mysql数据库外,还有一个空的数据库test,供用户测试使用。
    现在继续创建一个数据库testdb,并执行一系列sql语句看看mysql数据库的基本操作。
     
    创建数据库testdb:
    create database testdb;
     
    预防性创建数据库:
    create database if not testdb
     
    创建表:
    use testdb;
    create table table1(
    username varchar(12),
    password varchar(20));
     
    预防性创建表aaa:
    create table if not exists aaa(ss varchar(20));
     
    查看表结构:
    describe table1;
     
    插入数据到表table1:
    insert into table1(username,password) values
    ('leizhimin','lavasoft'),
    ('hellokitty','hahhahah');
    commit;
     
    查询表table1:
    select * from table1;
     
    更改数据:
    update table1 set password='hehe' where username='hellokitty';
    commit;
     
    删除数据:
    delete from  table1 where username='hellokitty';
    commit;
     
    给表添加一列:
    alter table table1 add column(
      sex varchar(2) comment '性别',
      age date not null comment '年龄'
    );
    commit;
     
    从查询创建一个表table1
    create table tmp as
    select * from table1;
     
    删除表table1:
    drop table if exists table1;
    drop table if exists tmp;
     
    9、备份数据库testdb
    mysqldump -h 192.168.3.143 -u root -pleizhimin -x --default-character-set=gbk >C:\testdb.sql
     
    10、删除数据库testdb
    drop database testdb;
     
    11、恢复testdb数据库
    首先先建立testdb数据库,然后用下面命令进行本地恢复:
    mysql -u root -pleizhimin testdb <C:\testdb.sql
     
    12、删除mysql服务
    假如你厌倦mysql了,你需要卸载,那么你只需要这么做
     
    停止mysql服务
    net stop mysql5
     
    删除mysql服务
    sc delete mysql5

    然后删除msyql的安装文件夹,不留任何痕迹。
     

    Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1752641

  • 查找死锁的IIS进程

    2007-09-12 16:50:26Digest 4

    过IIS5的朋友都知道,如果ASP代码有缺陷,例如,死循环,或者代码中没能遵循数据库访问的开合原则,那么,就有可能引起IIS死锁.在IIS5下, 死锁是一件可怕的事,因为,服务器上任何一个IIS站点的死锁会导致IIS被阻塞,其结果是IIS进程CPU使用率很高,这样,所有对于WEB服务的访问 都无法得到回应
    IIS6中,防止死锁做的相当不错,而且IIS6中增加了池的概念,就是将若干个站点放在一个进程中执行,而这个进程W3WP,跟IIS的进程分离开来, 这样,即便有一个站点死锁,那么,只影响其所在的W3WP进程,而不会影响其他应用程序池.这个概念应该是得益于ASP.NET的应用程序域而来的.另 外,IIS6聪明的一点还在于,如果发生死锁,持续一段时间后,IIS会自动终止这个W3WP进程,重新为其建立新的进程,用于处理请求,这样,就避免一 直死锁下去.看来,IIS6中这种将IIS进程,处理请求的工作进程分离开来的做法,确不错
    但是,光解决问题还不行,通常,如果你不想这种情况反复发生的话,你就应该找出那个导致死锁的站点,然后将其隔离并检查ASP代码.对于一个管理员来说, 这不是一件容易的事.因为,通常一台服务器,可能有几十甚至上百个站点,这样,你也不知道哪个池对应于哪个W3WP进程,因此,就算你知道死锁进程的 PID,你也不知道应用程序池的名字.
    幸好,IIS6提供了一套不错的IIS管理脚本,当死锁时,使用
    iisapp -a
    就可以列出每一个IIS应用程序池与W3WP进程ID对应的关系.这样,我们由死锁进程ID就可以逆查出其对应的池的名称.

    然后,我们就可以将范围缩小到一个池中.然后,对池中的几个网站逐一排查了
    这真是一套非常有用的工具
  • JavaScript获得鼠标的X,Y坐标

    2007-09-12 16:25:42Digest 5

    JavaScript获得鼠标的X,Y坐标

    <script language="javascript">
    //取鼠标位置
    document.onmousemove = mouseMove;
    var mouse_x,mouse_y;
    function mouseMove(e) {
        if(!document.all){
            mouse_x=e.pageX;
            mouse_y=e.pageY;
        }else{
            mouse_x=document.body.scrollLeft+event.clientX;
            mouse_y=document.body.scrollTop+event.clientY;
        }
        //便于跟踪调试
        window.status = "x= " + mouse_x + " y= " + mouse_y;
    }

    //返回x坐标
    function getX()
    {
        return mouse_x;
    }

    //返回y坐标
    function getY()
    {
        return mouse_y;
    }
    </script>
  • 实现<A>标记中的Title换行

    2007-09-06 11:37:41Digest 5

    <!-- 开始 主体内容 -->
    [摘 要]</p><span class="checkoutHeader"><strong>本篇详细介绍了实现<A>标记中的Title换行的文章主题。</strong></span> <br>
    <br>
    <div class="content">
                    <p>&nbsp;</p>
    </div>
    <P></p></P>
    <p align="left">用&amp;#13;或&amp;#10;代替换行符可以实现换行,如下例子:</p>
    <p align="center"><br>
    <br>
    <br>
                    <textarea class="fm" id="code" rows="12" cols="78">&lt;a
    title="网站简介:&amp;#13;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;欧美网站截图,技术文档,网站模板,网站评论"
    href="http://www.webdn.com" target="_blank"&gt;网站每日新&lt;/a&gt;</textarea>
    </p>
    <input style="" onfocus="this.blur()" onclick="runEx('code')" value="运行代码" type="button">
    ?
    <input style="width: 95px;" onfocus="this.blur()" onclick="cycode(code)" value="复制到剪贴板" name="Submit" type="button">
    ?
    <input style="" onfocus="this.blur()" onclick="svcode(code)" value="另存代码" type="button">
    [Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
  • wget抓取网站用法

    2007-08-28 11:47:57

    Wget可以下载http和ftp网站文件,小命令但功能强,它的参数很多,但常用的不多。

    一. 下载整个网站:

    wget --mirror [--convert-links] http://www.gnu.org/
    或短写参数:
    wget -m [-k] http://www.gnu.org

    --mirror或-m:镜像整个网站,它与“-r -l inf -N”这三个参数一起用效果相同

    --recursive或-r:以递归方式抓取
    --level=depth或-l depth:递归的深度,缺省最大值为5,0或inf表示无限多
    --timestamping或-N:时间戳,不知道有什么用

    --convert-links或-k:在全部下载完成之后,修改已下载页面中的链接,如果链接所指向的文件也下在本地了,就指向这个文件,否则,就指向http上原来的文件

    二. 其它有用的参数:

    --tries=number 或 -t number:指定连接失败时重试次数,0或inf表示无限重试,缺省值为20。但如果遇到“连接被拒绝”或“文件没找到(404)”之类的错误,则不重试

    --output-document=file或-O file:指定输出文件名。比如:wget http://xxx.com/index.html -O abc.htm 将以abc.htm保存文件

    --no-clobber或-nc:通常在遇到下下来的文件重名,wget将为后下的文件加上‘.1’,‘.2’等加以区分。如果用了这个参数,则一旦后下的文件将与先下的同名,将不再下载后下的文件而保留先下的不变

    --no-directories或-nd:保存文件时,即使原来不在一起的文件,也不创建文件夹,所有文件全放在当前目录下

    --page-requisites或-p:下载html文件时,把与它有关的图片,声音,脚本等相关文件一同下下来

    * 所有参数都可以根据需要灵活搭配,不是固定的

    三. 例子:

    最简单的用法:
    wget http://download.xxx.com/soft/software.tar.gz

    指定输出文件名:
    wget http://www.xxx.com -O myname.htm

    下载html版的‘linux设备驱动’:
    wget --mirror http://www.deansys.com/doc/ldd3/index.html
    这样,从这个页面开始的所有页面全被抓下来,也就是这本书,嘿嘿~~。

    * 参考资料:wget manpage.
  • RTM、RC、CTP版本的含义

    2007-08-22 11:31:07Digest 5

    RTM、RC、CTP版本的含义

    RTM版是最终压盘版,Release To Manufacturing,也就是交付给光盘制作厂商,这和最终发布版一样。发布RTM后,厂商若要修改就只有通过发布SP来完成了。

    RC版是发布候选版,Release Candidate,一般是RTM版本前的几个预览版,但是这个阶段来说基本功能已经完成,主要是用来捉bug了,所以发布RC后,基本功能不会有大的变化了,只要各种测试能够通过,这也表明最终发布不远了。

    CTP是社群技术预览版,Community Technology Preview,这个版本只是用来在社区内发布,验证市场情况和用户认可度,早于RC版,就像Atlas,在发布了多个CTP后,突然剑峰一转,变为了ASP.NET AJAX,让前期投入大量精力在Atlas上,如dflying chen他们就相当郁闷,所以说CTP版本不一定可靠,可能在功能上都会有大的变化。 

  • php中文转拼音

    2007-08-12 13:27:54Digest 4

    <?php
    $dictionary = array(
        array("a", -20319),
        array("ai", -20317),
        array("an", -20304),
        array("ang", -20295),
        array("ao", -20292),
        array("ba", -20283),
        array("bai", -20265),
        array("ban", -20257),
        array("bang", -20242),
        array("bao", -20230),
        array("bei", -20051),
        array("ben", -20036),
        array("beng", -20032),
        array("bi", -20026),
        array("bian", -20002),
        array("biao", -19990),
        array("bie", -19986),
        array("bin", -19982),
        array("bing", -19976),
        array("bo", -19805),
        array("bu", -19784),
        array("ca", -19775),
        array("cai", -19774),
        array("can", -19763),
        array("cang", -19756),
        array("cao", -19751),
        array("ce", -19746),
        array("ceng", -19741),
        array("cha", -19739),
        array("chai", -19728),
        array("chan", -19725),
        array("chang", -19715),
        array("chao", -19540),
        array("che", -19531),
        array("chen", -19525),
        array("cheng", -19515),
        array("chi", -19500),
        array("chong", -19484),
        array("chou", -19479),
        array("chu", -19467),
        array("chuai", -19289),
        array("chuan", -19288),
        array("chuang", -19281),
        array("chui", -19275),
        array("chun", -19270),
        array("chuo", -19263),
        array("ci", -19261),
        array("cong", -19249),
        array("cou", -19243),
        array("cu", -19242),
        array("cuan", -19238),
        array("cui", -19235),
        array("cun", -19227),
        array("cuo", -19224),
        array("da", -19218),
        array("dai", -19212),
        array("dan", -19038),
        array("dang", -19023),
        array("dao", -19018),
        array("de", -19006),
        array("deng", -19003),
        array("di", -18996),
        array("dian", -18977),
        array("diao", -18961),
        array("die", -18952),
        array("ding", -18783),
        array("diu", -18774),
        array("dong", -18773),
        array("dou", -18763),
        array("du", -18756),
        array("duan", -18741),
        array("dui", -18735),
        array("dun", -18731),
        array("duo", -18722),
        array("e", -18710),
        array("en", -18697),
        array("er", -18696),
        array("fa", -18526),
        array("fan", -18518),
        array("fang", -18501),
        array("fei", -18490),
        array("fen", -18478),
        array("feng", -18463),
        array("fo", -18448),
        array("fou", -18447),
        array("fu", -18446),
        array("ga", -18239),
        array("gai", -18237),
        array("gan", -18231),
        array("gang", -18220),
        array("gao", -18211),
        array("ge", -18201),
        array("gei", -18184),
        array("gen", -18183),
        array("geng", -18181),
        array("gong", -18012),
        array("gou", -17997),
        array("gu", -17988),
        array("gua", -17970),
        array("guai", -17964),
        array("guan", -17961),
        array("guang", -17950),
        array("gui", -17947),
        array("gun", -17931),
        array("guo", -17928),
        array("ha", -17922),
        array("hai", -17759),
        array("han", -17752),
        array("hang", -17733),
        array("hao", -17730),
        array("he", -17721),
        array("hei", -17703),
        array("hen", -17701),
        array("heng", -17697),
        array("hong", -17692),
        array("hou", -17683),
        array("hu", -17676),
        array("hua", -17496),
        array("huai", -17487),
        array("huan", -17482),
        array("huang", -17468),
        array("hui", -17454),
        array("hun", -17433),
        array("huo", -17427),
        array("ji", -17417),
        array("jia", -17202),
        array("jian", -17185),
        array("jiang", -16983),
        array("jiao", -16970),
        array("jie", -16942),
        array("jin", -16915),
        array("jing", -16733),
        array("jiong", -16708),
        array("jiu", -16706),
        array("ju", -16689),
        array("juan", -16664),
        array("jue", -16657),
        array("jun", -16647),
        array("ka", -16474),
        array("kai", -16470),
        array("kan", -16465),
        array("kang", -16459),
        array("kao", -16452),
        array("ke", -16448),
        array("ken", -16433),
        array("keng", -16429),
        array("kong", -16427),
        array("kou", -16423),
        array("ku", -16419),
        array("kua", -16412),
        array("kuai", -16407),
        array("kuan", -16403),
        array("kuang", -16401),
        array("kui", -16393),
        array("kun", -16220),
        array("kuo", -16216),
        array("la", -16212),
        array("lai", -16205),
        array("lan", -16202),
        array("lang", -16187),
        array("lao", -16180),
        array("le", -16171),
        array("lei", -16169),
        array("leng", -16158),
        array("li", -16155),
        array("lia", -15959),
        array("lian", -15958),
        array("liang", -15944),
        array("liao", -15933),
        array("lie", -15920),
        array("lin", -15915),
        array("ling", -15903),
        array("liu", -15889),
        array("long", -15878),
        array("lou", -15707),
        array("lu", -15701),
        array("lv", -15681),
        array("luan", -15667),
        array("lue", -15661),
        array("lun", -15659),
        array("luo", -15652),
        array("ma", -15640),
        array("mai", -15631),
        array("man", -15625),
        array("mang", -15454),
        array("mao", -15448),
        array("me", -15436),
        array("mei", -15435),
        array("men", -15419),
        array("meng", -15416),
        array("mi", -15408),
        array("mian", -15394),
        array("miao", -15385),
        array("mie", -15377),
        array("min", -15375),
        array("ming", -15369),
        array("miu", -15363),
        array("mo", -15362),
        array("mou", -15183),
        array("mu", -15180),
        array("na", -15165),
        array("nai", -15158),
        array("nan", -15153),
        array("nang", -15150),
        array("nao", -15149),
        array("ne", -15144),
        array("nei", -15143),
        array("nen", -15141),
        array("neng", -15140),
        array("ni", -15139),
        array("nian", -15128),
        array("niang", -15121),
        array("niao", -15119),
        array("nie", -15117),
        array("nin", -15110),
        array("ning", -15109),
        array("niu", -14941),
        array("nong", -14937),
        array("nu", -14933),
        array("nv", -14930),
        array("nuan", -14929),
        array("nue", -14928),
        array("nuo", -14926),
        array("o", -14922),
        array("ou", -14921),
        array("pa", -14914),
        array("pai", -14908),
        array("pan", -14902),
        array("pang", -14894),
        array("pao", -14889),
        array("pei", -14882),
        array("pen", -14873),
        array("peng", -14871),
        array("pi", -14857),
        array("pian", -14678),
        array("piao", -14674),
        array("pie", -14670),
        array("pin", -14668),
        array("ping", -14663),
        array("po", -14654),
        array("pu", -14645),
        array("qi", -14630),
        array("qia", -14594),
        array("qian", -14429),
        array("qiang", -14407),
        array("qiao", -14399),
        array("qie", -14384),
        array("qin", -14379),
        array("qing", -14368),
        array("qiong", -14355),
        array("qiu", -14353),
        array("qu", -14345),
        array("quan", -14170),
        array("que", -14159),
        array("qun", -14151),
        array("ran", -14149),
        array("rang", -14145),
        array("rao", -14140),
        array("re", -14137),
        array("ren", -14135),
        array("reng", -14125),
        array("ri", -14123),
        array("rong", -14122),
        array("rou", -14112),
        array("ru", -14109),
        array("ruan", -14099),
        array("rui", -14097),
        array("run", -14094),
        array("ruo", -14092),
        array("sa", -14090),
        array("sai", -14087),
        array("san", -14083),
        array("sang", -13917),
        array("sao", -13914),
        array("se", -13910),
        array("sen", -13907),
        array("seng", -13906),
        array("sha", -13905),
        array("shai", -13896),
        array("shan", -13894),
        array("shang", -13878),
        array("shao", -13870),
        array("she", -13859),
        array("shen", -13847),
        array("sheng", -13831),
        array("shi", -13658),
        array("shou", -13611),
        array("shu", -13601),
        array("shua", -13406),
        array("shuai", -13404),
        array("shuan", -13400),
        array("shuang", -13398),
        array("shui", -13395),
        array("shun", -13391),
        array("shuo", -13387),
        array("si", -13383),
        array("song", -13367),
        array("sou", -13359),
        array("su", -13356),
        array("suan", -13343),
        array("sui", -13340),
        array("sun", -13329),
        array("suo", -13326),
        array("ta", -13318),
        array("tai", -13147),
        array("tan", -13138),
        array("tang", -13120),
        array("tao", -13107),
        array("te", -13096),
        array("teng", -13095),
        array("ti", -13091),
        array("tian", -13076),
        array("tiao", -13068),
        array("tie", -13063),
        array("ting", -13060),
        array("tong", -12888),
        array("tou", -12875),
        array("tu", -12871),
        array("tuan", -12860),
        array("tui", -12858),
        array("tun", -12852),
        array("tuo", -12849),
        array("wa", -12838),
        array("wai", -12831),
        array("wan", -12829),
        array("wang", -12812),
        array("wei", -12802),
        array("wen", -12607),
        array("weng", -12597),
        array("wo", -12594),
        array("wu", -12585),
        array("xi", -12556),
        array("xia", -12359),
        array("xian", -12346),
        array("xiang", -12320),
        array("xiao", -12300),
        array("xie", -12120),
        array("xin", -12099),
        array("xing", -12089),
        array("xiong", -12074),
        array("xiu", -12067),
        array("xu", -12058),
        array("xuan", -12039),
        array("xue", -11867),
        array("xun", -11861),
        array("ya", -11847),
        array("yan", -11831),
        array("yang", -11798),
        array("yao", -11781),
        array("ye", -11604),
        array("yi", -11589),
        array("yin", -11536),
        array("ying", -11358),
        array("yo", -11340),
        array("yong", -11339),
        array("you", -11324),
        array("yu", -11303),
        array("yuan", -11097),
        array("yue", -11077),
        array("yun", -11067),
        array("za", -11055),
        array("zai", -11052),
        array("zan", -11045),
        array("zang", -11041),
        array("zao", -11038),
        array("ze", -11024),
        array("zei", -11020),
        array("zen", -11019),
        array("zeng", -11018),
        array("zha", -11014),
        array("zhai", -10838),
        array("zhan", -10832),
        array("zhang", -10815),
        array("zhao", -10800),
        array("zhe", -10790),
        array("zhen", -10780),
        array("zheng", -10764),
        array("zhi", -10587),
        array("zhong", -10544),
        array("zhou", -10533),
        array("zhu", -10519),
        array("zhua", -10331),
        array("zhuai", -10329),
        array("zhuan", -10328),
        array("zhuang", -10322),
        array("zhui", -10315),
        array("zhun", -10309),
        array("zhuo", -10307),
        array("zi", -10296),
        array("zong", -10281),
        array("zou", -10274),
        array("zu", -10270),
        array("zuan", -10262),
        array("zui", -10260),
        array("zun", -10256),
        array("zuo", -10254)
    );
    function transform($num){
        global $dictionary;
        if ($num > 0 && $num < 160) {
            return chr($num);
        }
        elseif ($num < -20319 || $num > -10247) {
            return "";
        }
        else {
            for ($i = count($dictionary) - 1; $i >= 0; $i--) {
                if ($dictionary[$i][1] <= $num) {
                    break;
                }
            }
            return $dictionary[$i][0];
        }
    }
    function zh2pinyin($string)
    {
        $output = "";
        for ($i=0; $i < strlen($string); $i++) {
            $letter = ord(substr($string, $i, 1));
            if($letter > 160){
                $tmp = ord(substr($string, ++$i, 1));
                $letter = $letter * 256 + $tmp - 65536;
            }
            $output .= transform($letter);
        }
        return $output;
    }
    echo zh2pinyin($_POST['zh']);
    ?>
    <form method=post method="test.php">
    输入中文<input name="zh">
    <input type="submit">
  • 网页防拷贝和禁止另存为代码

    2007-08-11 08:29:37Digest 5

    网页防拷贝和禁止另存为代码  
      

    1、防拷贝代码
    <body leftmargin=0 topmargin=0  oncontextmenu=’return false’ ondragstart=’return false’ onselectstart =’return false’ onselect=’document.selection.empty()’ oncopy=’document.selection.empty()’ onbeforecopy=’return false’ onmouseup=’document.selection.empty()’>


    2、防“另存为”代码
    <noscript>
    <iframe src=*></iframe>
    </noscript>
  • PHP中获取网卡MAC地址

    2007-07-13 13:36:12Digest 4

     PHP中如何得到网卡MAC地址     选择自 blueoxygen 的 Blog
    关键字       PHP中如何得到网卡MAC地址
    出处     
        此文章资料完全从由互联网英文站点得到,当初为了回答网友问题,写得和引用的英文。都很简单,希望大家有耐心看下去。
     first i will share some basic thing of MAC address on internet.what happens?
    look :

    Because of the way that the internet was designed and the way that the IP protocol works, you wouldn't be able to find a mac address of someone unless you were local to them. The post earlier about using ping and arp is correct. The mac address is put into the IP packet at the 2nd level of the OSI model, its a physical address... once you go out through a router the mac address of the reported packet is changed, and is changed each and every time.. think of the mac as a "Return" address. You send out a packet and it goes across the country, and goes through 5 routers, the mac address on the packet will change each and every time it goes through a router, where the IP address won't. It's a type of routing code that the routers use to identify where the packet came from and where to send a response to.

    example

    Machine A sends a packet to Machine B, and it passes through Firewall C and D. The packet does this:

    Machine A sends the packet to firewall C, firwall C repackages the packet with its mac address and looks for the quickest route to machine B, it determines that firewall D is the closest to it, so it repackages the packet with its own mac address (since that is where D will send a response to if it cant get to machine smile_blackeye.gif and sends it on to D.. D does the exact same thing and sends the packet to B. Once Machine B receives the packet the entire process starts over again, the last mac address that is reported is for firewall D, but the IP points to Machine A, thats how it knows where to go.


    but there is still a function!!
    function returnMacAddress() {
    // This code is under the GNU Public Licence
    // Written by michael_stankiewicz {don't spam} at yahoo {no spam} dot com
    // Tested only on linux, please report bugs

    // WARNING: the commands 'which' and 'arp' should be executable
    // by the apache user; on most linux boxes the default configuration
    // should work fine

    // Get the arp executable path
    $location = `which arp`;
    // Execute the arp command and store the output in $arpTable
    $arpTable = `$location`;
    // Split the output so every line is an entry of the $arpSplitted array
    $arpSplitted = split("\n",$arpTable);
    // Get the remote ip address (the ip address of the client, the browser)
    $remoteIp = $GLOBALS['REMOTE_ADDR'];
    // Cicle the array to find the match with the remote ip address
    foreach ($arpSplitted as $value) {
    // Split every arp line, this is done in case the format of the arp
    // command output is a bit different than expected
    $valueSplitted = split(" ",$value);
    foreach ($valueSplitted as $spLine) {
    if (preg_match("/$remoteIp/",$spLine)) {
    $ipFound = true;
    }
    // The ip address has been found, now rescan all the string
    // to get the mac address
    if ($ipFound) {
    // Rescan all the string, in case the mac address, in the string
    // returned by arp, comes before the ip address
    // (you know, Murphy's laws)
    reset($valueSplitted);
    foreach ($valueSplitted as $spLine) {
    if (preg_match("/[0-9a-f][0-9a-f][:-]".
    "[0-9a-f][0-9a-f][:-]".
    "[0-9a-f][0-9a-f][:-]".
    "[0-9a-f][0-9a-f][:-]".
    "[0-9a-f][0-9a-f][:-]".
    "[0-9a-f][0-9a-f]/i",$spLine)) {
    return $spLine;
    }
    }
    }
    $ipFound = false;
    }
    }
    return false;
    }
    as mentioned before, be sure to understand the basics of the arp table since you can be sure that the obtained mac address is the right one only if the client is connected DIRECTLY to the php server,
    if there are routers or gateways that NAT the traffic, the returned mac address will be that of the gateway, not the client beside it
  • PHP获取服务器网卡的MAC地址

    2007-07-13 13:36:12Digest 3

    PHP获取网卡的MAC地址

                                          

    目前支持WIN/LINUX系统;至于AIX等,各位大虾有和高见!获取服务器的MAC地址,并不是用户端的。
    <?php
    /**
            获取机器网卡的物理(MAC)地址
            wwa  $Exp
    **/
    class GetMacAddr
    {
            var $return_array = array(); // 返回带有MAC地址的字串数组
            var $mac_addr;
           
            function GetMacAddr($os_type)
            {
                    switch ( strtolower($os_type) )
                    {
                            case "linux":
                                    $this->forLinux();
                                    break;
                            case "solaris":
                                    break;
                            case "unix":
                                    break;
                            case "aix":
                                    break;
                            default:
                                    $this->forWindows();
                                    break;
                    }
                   
                    $temp_array = array();
                    foreach ( $this->return_array as $value )
                    {
                            if ( preg_match( "/[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f]/i", $value, $temp_array ) )
                            {
                                    $this->mac_addr = $temp_array[0];
                                    break;
                            }
                    }
                    unset($temp_array);
                    return $this->mac_addr;
            }

            function forWindows()
            {
                    @exec("ipconfig /all", $this->return_array);
                    if ( $this->return_array )
                            return $this->return_array;
                    else{
                            $ipconfig = $_SERVER["WINDIR"]."\system32\ipconfig.exe";
                            if ( is_file($ipconfig) )
                                    @exec($ipconfig." /all", $this->return_array);
                            else
                                    @exec($_SERVER["WINDIR"]."\system\ipconfig.exe /all", $this->return_array);
                            return $this->return_array;
                    }
            }

            function forLinux()
            {
                    @exec("ifconfig -a", $this->return_array);
                    return $this->return_array;
            }
    }
    ?>
    <?
    //$mac = new GetMacAddr(PHP_OS);
    //echo $mac->mac_addr;
    ?>

  • Windows登录类型知多少?

    2007-07-12 11:10:45Digest 4

    Windows登录类型知多少?
       

    如果你留意Windows系统的安全日志,在那些事件描述中你将会发现里面的“登录类型”并非全部相同,难道除了在键盘上进行交互式登录之外还有其它类型吗?不错,Windows为了让你从日志中获得更多有价值的信息,它细分了很多种登录类型,以便让你区分登录者到底是从本地登录,还是从网络登录,以及其它更多的登录方式。因为了解了这些登录方式,将有助于你从事件日志中发现可疑的黑客行为,并能够判断其攻击方式。
    下面我们就来详细地看看Windows的登录类型。
       登录类型2:交互式登录(Interactive)  这应该是你最先想到的登录方式吧,所谓交互式登录就是指用户在计算机的控制台上进行的登录,也就是在本地键盘上进行的登录,但不要忘记通过KVM登录仍然属于交互式登录,虽然它是基于网络的。
       登录类型3:网络(Network)  当你从网络的上访问一台计算机时在大多数情况下Windows记为类型3,最常见的情况就是连接到共享文件夹或者共享打印机时。另外大多数情况下通过网络登录IIS时也被记为这种类型,但基本验证方式的IIS登录是个例外,它将被记为类型8,下面将讲述。
       登录类型4:批处理(Batch)  当Windows运行一个计划任务时,“计划任务服务”将为这个任务首先创建一个新的登录会话以便它能在此计划任务所配置的用户账户下运行,当这种登录出现时,Windows在日志中记为类型4,对于其它类型的工作任务系统,依赖于它的设计,也可以在开始工作时产生类型4的登录事件,类型4登录通常表明某计划任务启动,但也可能是一个恶意用户通过计划任务来猜测用户密码,这种尝试将产生一个类型4的登录失败事件,但是这种失败登录也可能是由于计划任务的用户密码没能同步更改造成的,比如用户密码更改了,而忘记了在计划任务中进行更改。
       登录类型5:服务(Service)  与计划任务类似,每种服务都被配置在某个特定的用户账户下运行,当一个服务开始时,Windows首先为这个特定的用户创建一个登录会话,这将被记为类型5,失败的类型5通常表明用户的密码已变而这里没得到更新,当然这也可能是由恶意用户的密码猜测引起的,但是这种可能性比较小,因为创建一个新的服务或编辑一个已存在的服务默认情况下都要求是管理员或servers operators身份,而这种身份的恶意用户,已经有足够的能力来干他的坏事了,已经用不着费力来猜测服务密码了。
      登录类型7:解锁(Unlock)  你可能希望当一个用户离开他的计算机时相应的工作站自动开始一个密码保护的屏保,当一个用户回来解锁时,Windows就把这种解锁操作认为是一个类型7的登录,失败的类型7登录表明有人输入了错误的密码或者有人在尝试解锁计算机。
  • PHP has encountered an Access Violation解决方法总结

    2007-06-12 22:04:53Digest 3



    PHP has encountered an Access Violation解决方法总结

    这个问题不是很好处理,困惑了很多站长非常时间了
    主要出现在windows主机的服务器上。
    在php官方,http://bugs.php.net
    也能够查到两三千页的报告,他们官方也是束手无策,经过了11个小版本后,还是没有彻底解决
    http://bugs.php.net/search.php?cmd=display&search_for=PHP+has+encountered+an+Access&x=8&y=9

    目前我提供一下这几年我维护经验,我的一些民间解决办法

    第一种可能:
    去掉 php中 eaccelerator 的扩展
    这样做能够解决您的问题,不过可能会加重系统负担
    因为eaccelerator主要是为了节省系统资源的东西

    具体做法是找到php.ini
    如果是我帮您配置的,一般在c:/php/php.ini或者 c:/winnt/php.ini 或者c:/windows/php.ini

    去掉

    zend_extension_ts="C:\php\extensions\eaccelerator_win_xxx.dll"
    eaccelerator.shm_size="16"
    eaccelerator.cache_dir="c:\temp"
    eaccelerator.enable="1"
    eaccelerator.optimizer="1"
    eaccelerator.check_mtime="1"
    eaccelerator.debug="0"
    eaccelerator.filter=""
    eaccelerator.shm_max="0"
    eaccelerator.shm_ttl="0"
    eaccelerator.shm_prune_period="0"
    eaccelerator.shm_only="0"
    eaccelerator.compress="1"
    eaccelerator.compress_level="9"

    ea主要是在unix环境下开发的,但是作者忽略到windows实际上不像u主机那样,是没有u主机的那种内存共享机制的
    这个bug已经提交给他们了,希望0.9.5能够解决

    当然,如果您的机器这个问题不严重,建议还是保留,ea是一块非常优秀的Php缓存+加速软件
    配合zo使用,将会降低系统负担 50%-80%左右,提高负载能力、速度和效率 200%左右

    第二种可能
    session_save_path 需要设定一个实际的物理路径,并且该目录需要everyone的所有权限,类似U主机的0777

    第三种可能
    c:/winnt/temp 或者 c:/windows/temp
    也需要everyone的所有权限,类似U主机的0777

    第四种可能
    您的内存严重不足,查看一下,如果有问题,请加内存,最好是一次加两条
    比如加1G内存,最好是加2条一模一样的512M。否则没有启用双通道,效果也很一般

    第五种可能
    ZendOptimizer和php的搭配不是很好
    换个版本试试看
    目前比较稳定的搭配是
    php4.3.11+zo 2.5.10a
    或者php4.4.1+zo 3.0 beta2

    第六种可能
    这种多属于用win2003的用户
    他们在应用池中设定了限制
    比如多长时间回收,最大使用内存多少等等
    这些设置势必造成这个经典的php错误
    经过数以百计的测试,敢担保问题会出现在这里。

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

    php经常报错,显示PHP has encountered an Access Violation at XXXXXX很多人说,是php版本的问题,其实不然,可以从四个地方来看这个问题
    1,是否zend所需的dll文件所在目录给的权限不够,必须有读取和运行的权限
    2,是否使用的2003,设置过应用池,比如池中限制了什么什么,调整一下再试试看,是否好了,呵呵
    3,php.ini有两个地方没有设置,而且一些程序必须用到的
    A
    将;upload_tmp_dir该行的注释符,即前面的分号“;”去掉,使该行在php.ini文档中起作用。upload_tmp_dir是用来定义 上传文件存放的临时路径,在这里你还可以给其定义一个绝对路径,例如:upload_tmp_dir = d:upload  当然,此时你的d:upload目录必须有读写权限。
    这里我设置为
    upload_tmp_dir = c:\temp  (因为前面建立了这个文件夹,我图省事,呵呵)
    B
    出现这样的错误语句一般是因为你的php.ini中关于session.save_path一项没有设置好,解决的方法是将session.save_path和session.cookie_path 设置置为
       session_save_path = c:\temp
       session.cookie_path = c:\temp
       然后在c:\目录下建立一个temp目录,即可(前面我们的eaccelerarot正好用到,建立过这么一个文件夹)
  • table-layout:fixed 属性的解说

    2007-06-06 17:31:13

    table-layout:fixed 属性的解说

    如果想要一个table固定大小,里面的文字强制换行(尤其是在一长串英文文本,并且中间无空格分隔的情况下),以达到使过长的文字不撑破表格的目的,一般是使用样式:table-layout:fixed。但是在Firefox下面,会有一些问题,参考 Gmail的一些做法,做了几个测试,得出一种解决办法。
    例1:(IE浏览器)普通的情况
    CODE:
    <table border=1 width=80><tr><td>abcdefghigklmnopqrstuvwxyz 1234567890</td></tr></table>

    效果:
    可以看到width=80并没有起作用,表格被字符撑开了。
    例2:(IE浏览器)使用样式table-layout:fixed
    CODE:
    <style>.tbl {table-layout:fixed}</style><table class=tbl border=1 width=80><tr><td>abcdefghigklmnopqrstuvwxyz 1234567890</td></tr></table>

    效果:
    width=80起作用了,但是表格换行了。 例3:(IE浏览器)使用样式table-layout:fixed与nowrap
    CODE:
    <style>.tbl {table-layout:fixed}</style><table class=tbl border=1 width=80><tr><td nowrap>abcdefghigklmnopqrstuvwxyz 1234567890</td></tr></table>

    效果:width=80起作用了,换行也被干掉了。
    例4:(IE浏览器)在使用数值固定td大小情况下使用样式table-layout:fixed与nowrap
    CODE:
    <style>.tbl {table-layout:fixed}</style><table class=tbl border=1 width=80><tr><td width=20 nowrap>abcdefghigklmnopqrstuvwxyz 1234567890</td><td nowrap>abcdefghigklmnopqrstuvwxyz 1234567890</td></tr></table>

    效果:不幸发生了,第一个td的nowrap不起作用了
    例5:(IE浏览器)在使用百分比固定td大小情况下使用样式table-layout:fixed与nowrap
    CODE:
    <style>.tbl {table-layout:fixed}</style><table class=tbl border=1 width=80><tr><td width=25% nowrap>abcdefghigklmnopqrstuvwxyz 1234567890</td><td nowrap>abcdefghigklmnopqrstuvwxyz 1234567890</td></tr></table>

    效果:改成百分比,终于搞定了
    例6:(Firefox浏览器)在使用百分比固定td大小情况下使用样式table-layout:fixed与nowrap效果:把例5放到firefox下面,又ft了
    例7:(Firefox浏览器)在使用百分比固定td大小情况下使用样式table-layout:fixed与nowrap,并且使用div
    CODE:
    <style>.tbl {table-layout:fixed}.td {overflow:hidden;}</style><table class=tbl border=1 width=80><tr><td width=25% class=td nowrap><div>abcdefghigklmnopqrstuvwxyz 1234567890</div></td><td class=td nowrap><div>abcdefghigklmnopqrstuvwxyz 1234567890</div></td></tr></table>

    效果:天下终于太平了
    例8:(Firefox浏览器)在使用数值固定td大小情况下使用样式table-layout:fixed与nowrap,并且使用div
    CODE:
    <style>.tbl {table-layout:fixed}.td {overflow:hidden;}</style>


    CODE:
    <table class=tbl border=1 width=80><tr><td width=20 class=td nowrap><div>abcdefghigklmnopqrstuvwxyz 1234567890</div></td><td class=td nowrap><div>abcdefghigklmnopqrstuvwxyz 1234567890</div></td></tr></table>

    效果:nowrap又不起作用了 最终,例7是一个在IE和Firefox都可以完美解决页面强制换行问题的解决方案。
  • word-wrap同word-break的区别

    2007-06-06 17:30:10

    word-wrap同word-break的区别

    word-wrap:
    normal  Default. Content exceeds the boundaries of its container. 
    break-word Content wraps to next line, and a word-break occurs when necessary. 必要时会触发word-break。

    word-break:
    normal  Default. Allows line breaking within words. 好像是只对Asian text起作用。
    break-all Behaves the same as normal for Asian text, yet allows the line to break arbitrarily for non-Asian text. This value is suited to Asian text that contains some excerpts of non-Asian text. 
    keep-all Does not allow word breaking for Chinese, Japanese, and Korean. Functions the same way as normal for all non-Asian languages. This value is optimized for text that includes small amounts of Chinese, Japanese, or Korean. 

    总结如下:
    word-wrap是控制换行的。
    使用break-word时,是将强制换行。中文没有任何问题,英文语句也没问题。但是对于长串的英文,就不起作用。

    break-word是控制是否断词的。
    normal是默认情况,英文单词不被拆开。
    break-all,是断开单词。在单词到边界时,下个字母自动到下一行。主要解决了长串英文的问题。
    keep-all,是指Chinese, Japanese, and Korean不断词。即只用此时,不用word-wrap,中文就不会换行了。(英文语句正常。)


    ie下:
    使用word-wrap:break-word;所有的都正常。

    ff下:
    如这2个都不用的话,中文不会出任何问题。英文语句也不会出问题。但是,长串英文会出问题。
    为了解决长串英文,一般用word-wrap:break-word;word-break:break-all;。但是,此方式会导致,普通的英文语句中的单词会被断开(ie下也是)。

    目前主要的问题存在于 长串英文 和 英文单词被断开。其实长串英文就是一个比较长的单词而已。
    即英文单词应不应该被断开那?那问题很明显了,显然不应该被断开了。
    对于长串英文,就是恶意的东西,自然不用去管了。但是,也要想些办法,不让它把容器撑大。
    用:overflow:auto; ie下,长串会自动折行。ff下,长串会被遮盖。


    所以,综上,最好的方式是word-wrap:break-word;overflow:hidden;而不是word-wrap:break-word;word-break:break-all;。
    word-wrap:break-word;overflow:auto;在ie下没有任何问题。在ff下,长串会被遮住部分内容。

    另,测试代码如下:

    1.htm===================================================================

    <style>
    .c1{ width:300px;  border:1px solid red}
    .c2{ width:300px;word-wrap:break-word;  border:1px solid yellow}
    .c3{ width:300px;word-wrap:break-word;word-break:break-all;  border:1px solid green}
    .c4{ width:300px;word-wrap:break-word;word-break:keep-all; border:1px solid blue}
    .c5{ width:300px;word-break:break-all;  border:1px solid black}
    .c6{ width:300px;word-break:keep-all;  border:1px solid red}
    .c7{ width:300px;word-wrap:break-word;overflow:auto;  border:1px solid yellow}
    </style>

    .c1{ width:300px;  border:1px solid red}
    <div class="c1">
    safjaskflasjfklsajfklasjflksajflksjflkasjfksafj
    </div>
    <div class=c1>
    This is all English. This is all English. This is all English.
    </div>
    <div class=c1>
    全是中文的情况。全是中文的情况。全是中文的情况。
    </div>
    <div class=c1>
    中英文混排的情况。Chinese and English. 中英文混排的情况。Chinese and English. 
    </div>

    <br>
    .c2{ width:300px;word-wrap:break-word; border:1px solid yellow}
    <div class="c2">
    safjaskflasjfklsajfklasjflksajflksjflkasjfksafj
    </div>
    <div class=c2>
    This is all English. This is all English. This is all English.
    </div>
    <div class=c2>
    全是中文的情况。全是中文的情况。全是中文的情况。
    </div>
    <div class=c2>
    中英文混排的情况。Chinese and English. 中英文混排的情况。Chinese and English. 
    </div>

    <br>
    .c3{ width:300px;word-wrap:break-word;word-break:break-all;  border:1px solid green}
    <div class="c3">
    safjaskflasjfklsajfklasjflksajflksjflkasjfksafj
    </div>
    <div class=c3>
    This is all English. This is all English. This is all English.
    </div>
    <div class=c3>
    全是中文的情况。全是中文的情况。全是中文的情况。
    </div>
    <div class=c3>
    中英文混排的情况。Chinese and English. 中英文混排的情况。Chinese and English. 
    </div>

    <br>
    .c4{ width:300px;word-wrap:break-word;word-break:keep-all; border:1px solid blue}
    <div class="c4">
    safjaskflasjfklsajfklasjflksajflksjflkasjfksafj
    </div>
    <div class=c4>
    This is all English. This is all English. This is all English.
    </div>
    <div class=c4>
    全是中文的情况。全是中文的情况。全是中文的情况。
    </div>
    <div class=c4>
    中英文混排的情况。Chinese and English. 中英文混排的情况。Chinese and English. 
    </div>

    <br>
    .c5{ width:300px;word-break:break-all;  border:1px solid black}
    <div class="c5">
    safjaskflasjfklsajfklasjflksajflksjflkasjfksafj
    </div>
    <div class=c5>
    This is all English. This is all English. This is all English.
    </div>
    <div class=c5>
    全是中文的情况。全是中文的情况。全是中文的情况。
    </div>
    <div class=c5>
    中英文混排的情况。Chinese and English. 中英文混排的情况。Chinese and English. 
    </div>

    <br>
    .c6{ width:300px;word-break:keep-all;  border:1px solid red}
    <div class="c6">
    safjaskflasjfklsajfklasjflksajflksjflkasjfksafj
    </div>
    <div class=c6>
    This is all English. This is all English. This is all English.
    </div>
    <div class=c6>
    全是中文的情况。全是中文的情况。全是中文的情况。
    </div>
    <div class=c6>
    中英文混排的情况。Chinese and English. 中英文混排的情况。Chinese and English. 
    </div>

    <br>
    .c7{ width:300px;word-wrap:break-word;overflow:auto;  border:1px solid yellow}
    <div class="c7">
    safjaskflasjfklsajfklasjflksajflksjflkasjfksafj
    </div>
    <div class=c7>
    This is all English. This is all English. This is all English.
    </div>
    <div class=c7>
    全是中文的情况。全是中文的情况。全是中文的情况。
    </div>
    <div class=c7>
    中英文混排的情况。Chinese and English. 中英文混排的情况。Chinese and English. 
    </div>

     

  • js清理清理html标签

    2007-05-26 14:40:01Digest 2

    清理html标签


    <CENTER><textarea name="textar" cols="80" rows="15">
    <BR>如果<P>这是段落,
    <HR>那将只取得其中的文字
    </textarea><BR>
    <input type="button" onclick=click3() value="处理代码"></CENTER>
    <script>
    function click3(){
    textar.value=textar.value.replace(/<.*?>/g,"").replace(/ /g," ").replace(/\n/g,"")
    }
    </SCRIPT>
  • js清理word生成的HTML冗余代码

    2007-05-26 14:40:01Digest 2

    <script language="javascript">
    <!--
    function cleanWordHtml(html){
    // Remove all SPAN tags
    html = html.replace(/</?SPAN[^>]*>/gi, "");
    // Remove Class attributes
    html = html.replace(/<(w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;
    // Remove Style attributes
    html = html.replace(/<(w[^>]*) style="([^"]*)"([^>]*)/gi, "<$1$3") ;
    // Remove Lang attributes
    html = html.replace(/<(w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
    // Remove XML elements and declarations
    html = html.replace(/<\??xml[^>]*>/gi, "") ;
    // Remove Tags with XML namespace declarations: <o:p></o:p>
    html = html.replace(/</?w+:[^>]*>/gi, "") ;
    // Replace the &nbsp;
    html = html.replace(/&nbsp;/, " " );
    // Transform <P> to <DIV>
    var re = new RegExp("(<P)([^>]*>.*?)(</P>)","gi") ;
    // Different because of a IE 5.0 error
    html = html.replace( re, "<div$2</div>");return html;
    }
    //-->
    </script>
  • 正则表达式模式中使用的修正符

    2007-05-22 13:00:12Digest 4

    模式修正符
    模式修正符 -- 解说正则表达式模式中使用的修正符
    说明
    下面列出了当前在 PCRE 中可能使用的修正符。括号中是这些修正符的内部 PCRE 名。修正符中的空格和换行被忽略,其它字符会导致错误。



    i (PCRE_CASELESS)
    如果设定此修正符,模式中的字符将同时匹配大小写字母。

    m(PCRE_MULTILINE)
    默 认情况下,PCRE 将目标字符串作为单一的一“行”字符所组成的(甚至其中包含有换行符也是如此)。“行起始”元字符(^)仅仅匹配字符串的起始,“行结束”元字符($)仅 仅匹配字符串的结束,或者最后一个字符是换行符时其前面(除非设定了 D 修正符)。这和 Perl 是一样的。

    当设定了此修正符,“行起始”和“行结束”除了匹配整个字符串开头和结束外,还分别匹配其中的换行符的之后和之前。这和 Perl 的 /m 修正符是等效的。如果目标字符串中没有“\n”字符或者模式中没有 ^ 或 $,则设定此修正符没有任何效果。

    s(PCRE_DOTALL)
    如果设定了此修正符,模式中的圆点元字符(.)匹配所有的字符,包括换行符。没有此设定的话,则不包括换行符。这和 Perl 的 /s 修正符是等效的。排除字符类例如 [^a] 总是匹配换行符的,无论是否设定了此修正符。

    x(PCRE_EXTENDED)
    如 果设定了此修正符,模式中的空白字符除了被转义的或在字符类中的以外完全被忽略,在未转义的字符类之外的 # 以及下一个换行符之间的所有字符,包括两头,也都被忽略。这和 Perl 的 /x 修正符是等效的,使得可以在复杂的模式中加入注释。然而注意,这仅适用于数据字符。空白字符可能永远不会出现于模式中的特殊字符序列,例如引入条件子模式 的序列 (?( 中间。

    e
    如果设定了此修正符,preg_replace() 在替换字符串中对逆向引用作正常的替换,将其作为 PHP 代码求值,并用其结果来替换所搜索的字符串。

    只有 preg_replace() 使用此修正符,其它 PCRE 函数将忽略之。

    注意: 本修正符在 PHP3 中不可用。


    A(PCRE_ANCHORED)
    如果设定了此修正符,模式被强制为“anchored”,即强制仅从目标字符串的开头开始匹配。此效果也可以通过适当的模式本身来实现(在 Perl 中实现的唯一方法)。

    D(PCRE_DOLLAR_ENDONLY)
    如果设定了此修正符,模式中的美元元字符仅匹配目标字符串的结尾。没有此选项时,如果最后一个字符是换行符的话,美元符号也会匹配此字符之前(但不会匹配任何其它换行符之前)。如果设定了 m 修正符则忽略此选项。Perl 中没有与其等价的修正符。

    S
    当一个模式将被使用若干次时,为加速匹配起见值得先对其进行分析。如果设定了此修正符则会进行额外的分析。目前,分析一个模式仅对没有单一固定起始字符的 non-anchored 模式有用。

    U(PCRE_UNGREEDY)
    本修正符反转了匹配数量的值使其不是默认的重复,而变成在后面跟上“?”才变得重复。这和 Perl 不兼容。也可以通过在模式之中设定 (?U) 修正符或者在数量符之后跟一个问号(如 .*?)来启用此选项。

    X(PCRE_EXTRA)
    此 修正符启用了一个 PCRE 中与 Perl 不兼容的额外功能。模式中的任何反斜线后面跟上一个没有特殊意义的字母导致一个错误,从而保留此组合以备将来扩充。默认情况下,和 Perl 一样,一个反斜线后面跟一个没有特殊意义的字母被当成该字母本身。当前没有其它特性受此修正符控制。

    u(PCRE_UTF8)
    此 修正符启用了一个 PCRE 中与 Perl 不兼容的额外功能。模式字符串被当成 UTF-8。本修正符在 Unix 下自 PHP 4.1.0 起可用,在 win32 下自 PHP 4.2.3 起可用。自 PHP 4.3.5 起开始检查模式的 UTF-8 合法性。
1091/6123456>

数据统计

  • 访问量: 12405
  • 日志数: 8
  • 文件数: 1
  • 建立时间: 2007-04-05
  • 更新时间: 2008-02-20

RSS订阅

Open Toolbar