用eclipse和pdt配置php开发及调试环境

一、安装apache,mysql,php

下载php,地址:http://www.php.net/releases/
apache和mysql都下安装包,双击运行,选择要安装的目录,一直点击下一步就可以安装成功。
注意:安装apache的时候要保证80端口没有被占用,否则会安装不成功。如果在运行iis和skype,在安装之前都先停掉。
对于php,下载zip文件,解压到某个目录就行。

二、配置apche,mysql,php

对于php4
1) 将php.ini-dist更名为php.ini。并复制到windows/system32下 面或者复制到 apache/bin下面。并修改php.ini
找到extension=php_mysql.dll, 把前面的分号(;)去掉。
2) 修改httpd.conf。添加:
AddType application/x-httpd-php .php
LoadFile "C:/php-4.4.6/php4ts.dll"
LoadModule php4_module "C:/php-4.4.6/sapi/php4apache2.dll"
找到DirectoryIndex index.html index.html.var 在后面加入 index.php
3) 保存修改。重新启动apache服务器。
对于php5
1) php.ini-recommended更名为php.ini。并复制到windows/system32下面 或者复制到 apache/bin下面。并修改php.ini
找到extension=php_mysql.dll, 把前面的分号(;)去掉。
2) 修改httpd.conf。添加:
AddType application/x-httpd-php .php
LoadModule php5_module "C:/php5/php5apache2.dll"
找到DirectoryIndex index.html index.html.var 在后面加入 index.php
3)保存修改。重新启动apache服务器

三、下载pdt。下载带有zenddebug的all-in-one版本

地址:http://downloads.zend.com/pdt/all-in-one/pdt-1.0.3.R20080603_debugger-5.2.14.v20080602-all-in-one-win32.zip

四、下载ZendDebugger

因为pdt all-in-one中的ZendDebugger.dll的版本可能和你系统中php的版本不兼容,所以最好单独下载一个。
地址:http://downloads.zend.com/pdt/server-debugger/ZendDebugger-5.2.14- cygwin_nt-i386.zip
解压后,可以看到目录下有“5_0_x_comp”和“5_1_x_comp”等。该目录下的ZendDebugger.dll就是和相关的php版本对应。如果你的php是php5.0 就用5_0_x_comp下面的ZendDebugger.dll。如果你的php是php5.1就用5_1_x_comp下面的 ZendDebugger.dll。

五、apache,php的配置

我的apache安装在D:\phpProgram\Apache2
php安装在D:\phpProgram\php5
php.ini放在了D:\phpProgram \Apache2\bin下面。
1)将合适的ZendDebugger.dll复制到D:\phpProgram\php5\ext下面。
2)修改D:\phpProgram\Apache2\bin下面的php.ini
增加:
zend_extension_ts="D:\phpProgram\php5\ext\ZendDebugger.dll"
zend_debugger.allow_hosts=192.168.1.105,127.0.0.1
zend_debugger.expose_remotely=always
zend_debugger.connector_port = 10137
注:192.168.1.105就是你在命令提示符下输入ipconfig /all看到的本地连接的
IP Address右边的值。
如果提示ipconfig不是内部命令,那么可以进入windows的system32下面。输入 ipconfig /all.
3)修改D:\phpProgram\Apache2\conf下面的httpd.conf
增加:
Alias /phpWorks "D:/my works/phpWorks"
<Directory "D:/my works/phpWorks">
Options Indexes MultiViews ExecCGI
DirectoryIndex index.php
AllowOverride None
Order allow,deny
Allow from all
</Directory>
找到DocumentRoot 那一项改为:
DocumentRoot "D:/my works/phpWorks"

六、pdt的配置

1) 启动eclipse,双击eclipse.exe
2)选择工作目录为D:\my works\phpWorks
3) 点击windows>prefences
展开左侧面板中”PHP“下面的项目
展开”DeBug“,双击下面的Installed DeBuggers。
选择”Zend Debugger“,点击”Configure“。
在弹出的对话框 中,在Debug Port后面的输入框中输入10137,在Client Host/IP后面的输入框中输入192.168.1.105,127.0.0.1。点击”OK“。
双 击”PHP“下面,和” DeBug“同级的”PHP Executables“,点击”Add“。
在 弹出的对话框中,在name后面的输入框中输入php。
Executable Path为php.exe的路径,即 D:\phpProgram\php5\php.exe
PHP.ini file(optional)为php.ini的路径,即D:\phpProgram \Apache2\bin\php.ini。
PHP Debugger选择为Zend Debugger。点击”Finished“。
双击”PHP“下面,和” DeBug“同级的”PHP Servers“。
选择”Default PHP Web Server“,点击”Edit“。
在 弹出的对话框中,在”Server“选项卡下的Name后面的输入框中输入Default PHP Web Server,另一个输入框中输入http://localhost/phpWorks。
在”Path Mapping“选项卡中,点击”Add“。
在弹出的对话框中,在Path On Server下面的输入框中输入http://localhost/phpWorks,
在Path in File System下面的对话框中输入D:\my works\phpWorks。

七、重启eclipse,启动apache

WordPress使用ISAPI_ReWrite伪静态规则(URL重写规则)

形式1:年/月/日/Postname.html

# 形式:年/月/日/Postname.html
# 自定义链接 /%year%/%monthnum%/%day%/%postname%.html
# URL:http://www.junstyle.com.cn

RewriteRule /tag/(.*) /index\.php\?tag=$1
RewriteRule /(about|contact|about-copyright|favor|archives|tags|sitemap)/ /index\.php\?pagename=$1
RewriteRule /category/(.*)/(feed|rdf|rss|rss2|atom)/?$ /wp-feed\.php\?category_name=$1&feed=$2
RewriteRule /category/?(.*) /index\.php\?category_name=$1
RewriteRule /author/(.*)/(feed|rdf|rss|rss2|atom)/?$ /wp-feed\.php\?author_name=$1&feed=$2
RewriteRule /author/?(.*) /index\.php\?author_name=$1
RewriteRule /feed/?$ /wp-feed\.php/\?feed=rss2
RewriteRule /comments/feed/?$ /wp-feed\.php/\?feed=comments-rss2
RewriteRule /page/(.*)/ /index\.php\?paged=$1
RewriteRule /([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/?([0-9]+)?.html/?$ /index\.php\?year=$1&monthnum=$2&day=$3&name=$4&page=$5
RewriteRule /([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$ /index\.php\?year=$1&monthnum=$2&day=$3&page=$4
RewriteRule /([0-9]{4})/([0-9]{1,2})/?$ /index\.php\?year=$1&monthnum=$2&page=$3
RewriteRule /([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+).html/(feed|rdf|rss|rss2|atom)/?$ /index\.php\?year=$1&monthnum=$2&day=$3&name=$4&feed=$5
RewriteRule /([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+).html/trackback/?$ /wp-trackback\.php\?year=$1&monthnum=$2&day=$3&name=$4&tb=1

形式2:形式:年/月/日/Postname/

# 形式:年/月/日/Postname/
# 自定义链接 /%year%/%monthnum%/%day%/%postname%/
# URL:http://www.junstyle.com.cn

RewriteRule /tag/(.*) /index\.php\?tag=$1
RewriteRule /(about|contact|about-copyright|favor|archives|tags|sitemap)/ /index\.php\?pagename=$1
RewriteRule /category/(.*)/(feed|rdf|rss|rss2|atom)/?$ /wp-feed\.php\?category_name=$1&feed=$2
RewriteRule /category/?(.*)/ /index\.php\?category_name=$1
RewriteRule /author/(.*)/(feed|rdf|rss|rss2|atom)/?$ /wp-feed\.php\?author_name=$1&feed=$2
RewriteRule /author/?(.*) /index\.php\?author_name=$1
RewriteRule /feed/?$ /wp-feed\.php/\?feed=rss2
RewriteRule /comments/feed/?$ /wp-feed\.php/\?feed=comments-rss2
RewriteRule /page/(.*)/ /index\.php\?paged=$1
RewriteRule /([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/?([0-9]+)?/?$ /index\.php\?year=$1&monthnum=$2&day=$3&name=$4&page=$5
RewriteRule /([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$ /index\.php\?year=$1&monthnum=$2&day=$3&page=$4
RewriteRule /([0-9]{4})/([0-9]{1,2})/?$ /index\.php\?year=$1&monthnum=$2&page=$3
RewriteRule /([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/(feed|rdf|rss|rss2|atom)/?$ /index\.php\?year=$1&monthnum=$2&day=$3&name=$4&feed=$5
RewriteRule /([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/trackback/?$ /wp-trackback\.php\?year=$1&monthnum=$2&day=$3&name=$4&tb=1

形式3:/post/PostID.html

# 形式:/post/PostID.html
# 自定义链接 /post/%post_id%.html
# URL:http://www.junstyle.com.cn

RewriteRule /post/tag/(.*) /index\.php\?tag=$1
RewriteRule /tag/(.*) /index\.php\?tag=$1
RewriteRule /(about|contact|about-copyright|favor|archives|tags|sitemap|taotao) /index\.php\?pagename=$1
RewriteRule /post/category/(.*)/(feed|rdf|rss|rss2|atom)/?$ /wp-feed\.php\?category_name=$1&feed=$2
RewriteRule /post/category/?(.*) /index\.php\?category_name=$1
RewriteRule /author/(.*)/(feed|rdf|rss|rss2|atom)/?$ /wp-feed\.php\?author_name=$1&feed=$2
RewriteRule /author/?(.*) /index\.php\?author_name=$1
RewriteRule /rss.xml /wp-feed\.php/\?feed=rss2
RewriteRule /feed/?$ /wp-feed\.php/\?feed=rss2
RewriteRule /comments/feed/?$ /wp-feed\.php/\?feed=comments-rss2
# RewriteRule /([0-9]+)/?([0-9]+)?/?$ /index\.php\?p=$1&page=$2
# RewriteRule /post/([0-9]+)/?([0-9]+)?/?$ /index\.php\?p=$1&page=$2
RewriteRule /post/([0-9]+).html /index\.php\?p=$1 [I]
RewriteRule /page/(.*)/?s=(.*) /index\.php\?s=$2&paged=$1
RewriteRule /page/(.*) /index\.php\?paged=$1
RewriteRule /post/date/([0-9]{4})([0-9]{1,2})([0-9]{1,2})/([^/]+)/?([0-9]+)?/?$ /index\.php\?year=$1&monthnum=$2&day=$3&name=$4&page=$5
RewriteRule /post/date/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$ /index\.php\?year=$1&monthnum=$2&day=$3&page=$4
RewriteRule /post/date/([0-9]{4})/([0-9]{1,2})/?$ /index\.php\?year=$1&monthnum=$2&page=$3
RewriteRule /post/([0-9]+).html/(feed|rdf|rss|rss2|atom) /index\.php\?feed=rss2&p=$1
RewriteRule /post/([0-9]+).html/trackback /wp-trackback\.php\?p=$1

javascript中的getYear()在firefox下的问题

JS getYear在firefox下有问题

用了JS的getYear()方法,但是发现生成的代码竟然有108(本应该是2008),发现这是firefox下的问题。在 Firefox 里面 getYear 返回的是 "当前年份-1900" 的值,而IE里面则:当today的年份小于2000的时候,和firefox一样。当today的年份大于等于2000的时候 在返回的基础上额外加上1900 如:today年份是1999 返回99(同firefox) today年份是2000 返回100+1900=2000 所以最好用 getFullYear或者getUTCFullYear 去获取完整的年份 var year = today.getFullYear();在IE,FireFox都适用。

如:(js代码)

var today = new Date();

var fullyear = today.getFullYear();

var year = today.getYear();

document.write(fullyear + "<br>");

document.write(year + "<br>");

结果:

2010

110

一个求时间差的方法

function DateDiff(sDate1,sDate2){
//sDate1和sDate2是年-月-日格式
var arrDate,objDate1,objDate2,intDays;
arrDate=sDate1.split("-");
objDate1=new Date(arrDate[1]+'-'+arrDate[2]+'-'+arrDate[0]);//转换为月-日-年格式
arrDate=sDate2.split("-");
objDate2=new Date(arrDate[1]+'-'+arrDate[2]+'-'+arrDate[0]);
intDays=parseInt(Math.abs(objDate1-objDate2)/1000/60/60/24); //把相差的毫秒数转换为天数
return intDays;
}
alert(DateDiff("2007-1-1","2008-1-1"));

绕过图片防盗链的两个方法

方法一:使用iframe,这里iframe没有发送referer

<script>
window.sc="<img src='http://www.businessinfo.co.uk/labs/hackvertor/images/logo.gif?"+Math.random()+"'>";
</script>
<iframe src="javascript:parent.sc"></iframe>

方法二:使用https跳转到http

<img src=https://www.xxx.com/redirect?target=http://www.baidu.com/xxx.jpg />

利用在https下的一个第三方提供redirect的接口,重定向到http的一个页面,是不发送referer的。

参考自:http://hi.baidu.com/aullik5/blog/item/d55d97efca1333222df53445.html

wordpress半角引号变成全角引号问题的解决

这个问题困扰我很久了,一直都懒得处理,今天看到下面的文章可以解决。

不管是哪个语言版本的 WordPress,总会把文章中的'(英文单引号)替换成‘和’(中文单引号),把"(英文双引号)替换成“和”(中文双引号)。更有意思的是英文的三 个句号(...)居然会被转换为中文的半个省略号(…)。这么处理可能是基于方便数据库存储的考虑吧,或者也许WordPress的开发人员是中国人 吧:) 对于一般的文章没有什么问题,对于经常要在文章里面贴代码的人来说就麻烦了,因为中文引号的代码人家COPY回去是没法用的。

这个替换是在文件wp-includes/formatting.php中进行的。

解决方法:
修改位于”WordPress安装目录/wp-includes/”目录里面的”formatting.php”文件, 在第25行到第43行的这个for循环语句的第一个if条件里, 你应该能看到以下4行代码(或者你直接搜索这些代码查找也可以):

查找以下代码并注释掉:

// static strings
$curl = str_replace($static_characters, $static_replacements, $curl);
// regular expressions
$curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);

成为:

// static strings
//屏蔽转换为中文标点符号
//$curl = str_replace($static_characters, $static_replacements, $curl);
// regular expressions
//$curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);

保存即可。

此外,也有人编写了一个插件Quotmarks Replacer来处理这个事情。插件库里面可以搜索到,不想修改源代码的朋友可以使用这个插件。

原文作者博客

IE6下position:absolute定位错误的bug和解决方法

IE6确实太讨厌,但现在还是有很多用户,没办法。position:absolute定位在IE6下存在left和bottom的定位错误问题:

1. left 定位问题
<div style="position:relative;border:1px solid orange;text-align:right;">
<a href="http://www.junstyle.com.cn">http://www.junstyle.com.cn</a>
<div style="position:absolute;top:0;left:0;background:#ccc;">定位</div>
</div>

如果position:absolute的父层,也就是position:relative的层没有设置宽或高,那么在IE6下,出现left错位的 bug,其原因是没有触发haslayout。
解决方法:1. 给position:relative层加上width或height;2. 给position:relative层加上zoom:1,触发layout。

2. bottom定位问题:

<div style="position:relative;border:1px solid orange;text-align:center; zoom:1; ">
<a href="http://www.junstyle.com.cn">http://www.junstyle.com.cn</a>
<div style="position:absolute;bottom:0;left:0;background:#ccc;">定位< /div>
</div>

如果position:absolute的父层,也就是position:relative的层没有设置宽或高,那么在IE6下,出现bottom错位的 bug,其原因是没有触发haslayout。
解决方法:1. 给position:relative层加上width或height;2. 给position:relative层加上zoom:1,触发layout。

其中,还有一个问题,奇偶数问题,如果高度是奇数,在IE6下,会出现bottom:1px这样的现象,解决问题的办法就是把高度设为偶数。

IE6赶快淘汰吧!

javascript获取某个月的天数

Javascript里面的new Date("xxxx/xx/xx")这个日期的构造方法有一个妙处,当你传入的是"xxxx/xx/0"(0号)的话,得到的日期是"xx"月的前一个月的最后一天("xx"月的最大取值是69,题外话),如果传入"1999/13/0",会得到"1998/12/31"。而且最大的好处是当你传入"xxxx/3/0",会得到xxxx年2月的最后一天,它会自动判断当年是否是闰年来返回28或29,不用自己判断,太方便了!!所以,我们想得到选择年选择月有多少天的话,只需要

var d=new Date("选择年/选择月+1/0");

alert(d.getDate());

下面是使用Javascript编写的获取某年某月有多少天的getDaysInOneMonth(year, month)方法:

function getDaysInOneMonth(year, month){
month = parseInt(month,10)+1;
var d= new Date(year+"/"+month+"/0");
return d.getDate();
}

firefox无法初始化应用程序安全组件

今天关闭firefox,然后重启它又出现了这个错误:”无法初始化应用程序安全组件。很有可能您的程序个人目录中的文件出现问题。请检查并确认此目录没有读/写限制,而且您的硬盘没有写满或接近于写满。推荐您退出程序并修正问题。如果继续使用此会话,您在访问安全特性时将会看到程序运行发生错误。“,已经是第二次出现这个错误了,不知道是怎么回事,以前用32位的vista都没出现过这个错误,现在换了64位的win7老是出现这个问题,很是烦人,想想第一次处理这个问题时把我所有的浏览记录都搞不见了,这次出现问题一定要弄个安全的解决办法。在网上看到以下的解决方法,可能存在以下几种情况。

一、硬盘的容量不足

检查您的硬盘驱动器的剩余容量。为了做到 Windows机器上的:

1。打开我的电脑
2。右键单击在C:驱动器
3。选择属性。一个对话框将会出现。
4。转到常规选项卡

如果报告不到1MB的可用空间,您需要提供更大的空 间。

二、文件权限问题

检查您的配置文件夹中的文件权限。档名为 cert8.db不能是只读的。若要在Windows机器上的:

1。打开您的配置文件夹在Windows资源管理器。
2。右键单击该文件名为cert8.db。
3。选择属性。一个对话框将会出现。
4。转到常规选项卡
5。确保“只读”复选框未选中。
6。按确定。

三、文件已经损坏

在您的个人文件夹文件cert8.db可能已损坏。删 除这个文件,而应用程序(火狐,SeaMonkey,建立等)已关闭。[1]要做到这在Windows的机器:

1。关闭应用程序中选择文件 - >“退出。
2。打开您的配置文件夹在Windows资源管理器。
3。点击名为cert8.db文件。
4。按删除。
5。重新启动该应用程序。Cert8.db将重新创建 时,你这样做。

四、新建一个配置文件

实在无法解决的话,你只能创建一个新的配置文件了。具体操作方法:随便找个firefox的快捷方式,右键单击,选择“属性”,选择弹出选项卡顶部的”快捷方式“栏,在”目标“一项中,在文字 最后加入” -p“,然后”确定“。之后关掉所有已经在运行的firefox窗口,再双击刚刚修改过的firefox快捷方式,就会弹出一个窗口提示选择配置文件,新建一个配置文件即可。

c#:UNIX时间戳和DateTime的相互转换

// Unix时间戳格式转换为DateTime时间格式
public DateTime GetTime(string timeStamp)
{
    DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
    long lTime = long.Parse(timeStamp + "0000000");
    TimeSpan toNow = new TimeSpan(lTime);
    return dtStart.Add(toNow);
}

// DateTime时间格式转换为Unix时间戳格式
public int ConvertDateTimeInt(System.DateTime time)
{
    System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
    return (int)(time - startTime).TotalSeconds;
}

SQL Server2008:解决“阻止保存要求重新创建表的更改”

在SQL Server 2008企业管理器中更改表结构时(特别是修改了某个字段的类型时),总是会弹出:必须要先删除原来的表,然后重新创建新表,才能完成表的更改,如果强行更改会出现以下提示:不允许保存更改。您所做的 更改要求删除并重新创建以下表。您对无法重新创建的标进行了更改或者启用了“阻止保存要求重新创建表的更改”选项。如何避免此提示,可从“工具”菜单中 选择“选项”,在“选项”对话框中,选择Designers,选择“表设计器和数据库设计器”,清除“ 阻止保存要求重新创建表的更改”复选框。