PHP-Securimage图片验证码工具
What is Securimage?
Securimage is an open-source free PHP CAPTCHA script for generating complex images and CAPTCHA codes to protect forms from spam and abuse. It can be easily added into existing forms on your website to provide protection from spam bots. It can run on most any webserver as long as you have PHP installed, and GD support within PHP. Securimage does everything from generate complicated CAPTCHA images to making sure the code the user entered was correct.
* Check out the quickstart guide to get going fast
* See live example sites using Securimage
* Download the latest version
Securimage是一个开源的PHP验证码脚本,它可以生成复杂的验证码图像,用来保护论坛免于垃圾留言的干扰。
我们可以轻松的把它加入到已存在的论坛中。它可以在大部分安装了PHP的web服务器上运行,只要你安装了GD库。
Securimage生成复杂的验证码,并且会确认用户输入的正确性。
Securimage的Ajax版本所用的是prototype库,呵呵,个人更喜欢jQuery。
Drupal Themes
Learned from 《75 Great Drupal Themes》
Did not write a lot of days on the contents of the drupal,today just saw the article on noupe.com,so copy something here.
I will post a part of those themes which I think is most beautiful,if you want to see all of them,plz viste the URL on the top of this post.
GlossyBlue
This is a port of the GlossyBlue WordPress theme. It’s a two-column theme with a blue and green color-scheme. (Note: the screenshot is for the WP theme, but is virtually identical to the Drupal template).
(PS:Yes,it's WordPress theme~So many good theme is transformed to other sysytems.)
PHP-轻松实现多态
原文链接http://bbs.verylab.com/viewthread.php?tid=34,请尊重原创。
以下内容节选自作者的部分内容+豆腐的碎碎念:
PHP 5.x 虽然支持抽象类和接口, 但并不支持多态,那如何实现多态呢?可以借助接口来实现。
1. 建立 ITest.php 接口
< ?php
interface ITest
{
public function test($a, $b);
}
?>
2. 建立 TestLibary 文件夹, 在这个文件夹下定义的所有类都实现 ITest 接口, 以下是一些例子。
PerformanceTest.php
<?php
class PerformanceTest implements ITest
{
public function __construct()
{
//构造方法
}
public function test($a, $b)
{
//接口方法的实现
echo '我是 PerformanceTest 类';
}
}
DataTest.php
<?php
class DataTest implements ITest
{
public function __construct()
{
//构造方法
}
public function test($a, $b)
{
//接口方法的实现
echo '我是 DataTest 类';
}
}
以下省略,有兴趣的请参阅原文。个人觉得这是个不错的实现方法。
PHP-Web Client Class Snoopy
第1次看到Snoopy这个类是在Xiaonei的开放平台的PHP客户端上,当时很奇怪怎么会把类名命名成Snoopy,莫非程序员是个Snoopy控?
到今天在网上找资料的时候才忽然发现,原来Snoopy是个PHP的Web Client Class,那么这个东西具体可以干些啥呢?
资料来自http://www.linvo2008.cn/blog/?p=260
功能如下:
1、抓取网页的内容 fetch
2、抓取网页的文本内容 (去除HTML标签) fetchtext
3、抓取网页的链接,表单 fetchlinks fetchform
4、支持代理主机
5、支持基本的用户名/密码验证
6、支持设置 user_agent, referer(来路), cookies 和 header content(头文件)
7、支持浏览器重定向,并能控制重定向深度
8、能把网页中的链接扩展成高质量的url(默认)
9、提交数据并且获取返回值
10、支持跟踪HTML框架
11、支持重定向的时候传递cookies
Drupal-Smtp模组+HTML Mail模组
看段官方的介绍
This module allows Drupal to bypass the PHP mail() function and send email directly to an SMTP server. The module supports SMTP authentication and can even connect to servers using SSL if supported by PHP.
New features for Drupal 5.x include the ability to use SSL to connect to SMTP servers like gmail.
This module uses the smtp and mail class's from PHPMailer.
该模组是给不支持Mail的虚拟主机用的,官方地址:http://drupal.org/project/smtp
基于PHPMailer,但是并不是网上所说的要下载PHPMailer放到Smtp文件夹中才可以正常使用,事实上呢,Smtp内置了PHPMailer类。
如果大家以为开启该模组,并按照步骤设置好Smtp服务器,用户名,密码,测试邮件也可以收到就可以正常使用邮件服务的话,那就错了。
还有一个地方需要设置,那就是站点信息设置,也就是admin/settings/site-information,里边的邮件地址一定要和Smtp里的一样。
接着,就是要HTML化邮件内容了,官方那边类似模组很多,我下载的是HTML Mail,安装后启用就行了。
这样Drupal就会使用HTML格式发送Email了,来段官方的小介绍:
HTML Mail empowers Drupal with the ability to send emails in HTML.
This module presently is very simple in operation. It changes email headers in all outgoing mail to tell the recipient the email is in Raw HTML or "HTML email", as opposed to HTML as a multipart MIME attachment or embedded.
HTML emails are sometimes mandatory. For example, HTML emails are a must for sending RTL (Right To Left) language emails [full discussion].
By default, template tags are inserted and all you have to worry about is what goes between the body tags. There is an option to override this and an entire HTML document could then be inserted into the email body.
Remember that many email clients will not be happy with certain code, your CSS may conflict with webmail provider's CSS.
对了,设置HTML格式邮件的时候,记得把所有图片和链接地址都应该是绝对地址~
AS-AMFPHP AS和AMFPHP的数据交互
What's AMFPHP?官方的介绍如下:
AMFPHP is a free open-source PHP implementation of the Action Message Format(AMF). AMF allows for binary serialization of Action Script (AS2, AS3) native types and objects to be sent to server side services. AMFPHP is challenged with implementing the entire AMF protocol to be an alternative to Flex Data Services (AMF3) and Flash Remoting (AMF0). AMFPHP allows thin client applications built in languages such as Flash, Flex, and AIR to communicate directly with PHP class objects on the server. PHP developers can leverage their PHP experience in server side code development by connecting to data sources such as web-services, databases, and business applications and return that data to the client. Client applications can also offload cpu intensive methods to PHP services and wait for the result set for presentation to the user.......
官方的下载包虽然给了几个Demo,但是都没有操作数据库,刚好学习AMFPHP,做了个Demo,共享下,Demo如下:
PHP-输出RSS
其他语言的RSS输出类似,只要遵循RSS的输出规则就可以了。
PHP的代码示例如下:
< ?php
include "./config.php";//导入数据库配置文件
header("Content-type:application/xml");
//不知道为什么xml这句如果写到下边的html代码里会报错,搞不懂为什么……
echo "<?xml version='1.0' encoding='utf-8'?>\r\n";
?>
<!--rss格式开始-->
<!--rss声明-->
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
<channel about="http://nwhy.org">
<!--标题-->
<title>Flash Guestbook</title>
<!--链接地址-->
<link>http://nwhy.org</link>
<!--描述-->
<description>An Easy-to-use Flash Guestbook,Powered By nwhy.org.</description>
<!--语言-->
<language></language>
<!--版权-->
<copyright>nwhy.org</copyright>
< ?php
$sql="select * from rate limit 0,30";//获取数据
$rs=mysql_query($sql);
while($row=@mysql_fetch_array($rs)){
echo "<item>";
echo "<title>".$row['title']."</title>";//标题
echo "<guid>".$row['guid']."</guid>";//其他要输出的内容都可以在这里扩展
echo "<description>< ![CDATA[".$row['description']."]]></description>";//记得使用CDATA
echo "";
}
?>
</channel></rss>
<!--rss结束-->
Drupal-白宫新网站Recovery.gov
呵呵,前几天已经看到Recovery.gov,点进去稍微看了下,真是打死我都没想到这个站是基于Drupal的……
不过说来也对,Drupal是免费的,按照目前的经济状况,使用开源的程序可以节省纳税人的钱,对不?
第二呢,这也说明了白宫并没有就“社区合作开发的软件对于政府部门来说不够稳定和安全”的问题作过多的争辩。
第三,按理说,Drupal正在不断进步,它在民主政治方面有很深的根基,第一次引起政界注意的是Dean Space下的基金会出现,无论在哪个州,Drupal都拥有足够多的开发者社区进行开发。
最后,Recovery.gov采用Drupal标志着白宫正和Blue State Digital一起从事开源工作,该公司是奥巴马竞选时的Internet大本营。
作为社区共建的系统,Drupal依赖于开发者对代码进行改进,虽然白宫也可以开发出一些构建和节点,但终归还是的回到Drupal世界去。
哈哈,作为最近几年连续当选为最好的CMS系统的Drupal来说,这应该是理所当然的事。
---------------------------------------------------------------------------------------------------
话说这个星期的Drupal Camp议题是UI唉,还是Drupal官方的讲师,可惜最近忙着加班,应该不会安排去上海……
Utf8substr()修改自Discuz!的字符串截取函数
下边这段函数是从Discuz!扣出来的,是utf8的字符串截取,不会乱码,有需要的随便用,版权属于康盛~
/*
* utf8字符安全截取函数,注1个汉字为2个字符长度,如果长度截取到的是半个中文,该字符将不显示。
*
* $string 要截取的字符串
* $length 要截取的长度
* $dot 截取的长度小于字符串长度时候,返回的字符串结尾加上的字符,默认为'...'
*
* example:
* $test="一二><aaaa 三四)(_==*&%$";
* echo utf8substr($test,40,"<a href='xxx.php'>more");
* this result is:
* 一二></aaaa><aaaa 三四)(_==*<a href="xx.php">more
*/
function utf8substr($string, $length, $dot = '...') {
$charset='utf-8';
if(strlen($string) < = $length) {
$dot ="";
return $string;
}
$string = str_replace(array('&', '"', '<', '>'), array('&', '"', '<', '>'), $string);
$strcut = '';
if(strtolower($charset) == 'utf-8') {
$n = $tn = $noc = 0;
while($n < strlen($string)) {
$t = ord($string[$n]);
if($t == 9 || $t == 10 || (32 <= $t && $t <= 126)) {
$tn = 1; $n++; $noc++;
} elseif(194 <= $t && $t <= 223) {
$tn = 2; $n += 2; $noc += 2;
} elseif(224 <= $t && $t < 239) {
$tn = 3; $n += 3; $noc += 2;
} elseif(240 <= $t && $t <= 247) {
$tn = 4; $n += 4; $noc += 2;
} elseif(248 <= $t && $t <= 251) {
$tn = 5; $n += 5; $noc += 2;
} elseif($t == 252 || $t == 253) {
$tn = 6; $n += 6; $noc += 2;
} else {
$n++;
}
if($noc >= $length) {
break;
}
}
if($noc > $length) {
$n -= $tn;
}
$strcut = substr($string, 0, $n);
} else {
for($i = 0; $i < $length; $i++) {
$strcut .= ord($string[$i]) > 127 ? $string[$i].$string[++$i] : $string[$i];
}
}
$strcut = str_replace(array('&', '"', '< ', '>'), array('&', '"', '<', '>'), $strcut);
return $strcut.$dot;
}
Discuz7!批量上传失败的解决办法
发现论坛最近批量上传附件总是提示框显示成功,上传处显示失败!而单个附件上传却是没有问题,甚至有些用户可以正常批量上传!真是莫名其妙的问题?!文件都是官方的没有做过修改,谁能告诉我,这是啥情况?
G来G去,没有结果,去官方论坛搜索,呀,似乎有个有用的办法:
模板文件的post.htm
'src', 'images/common/upload.swf?site=misc.php',
改成
'src', 'images/common/upload.swf?site={$boardurl}misc.php',
唉,莫名其妙的奇怪,我又没改过这个文件。。碰到同样的问题,可以试试这个法子,或许有用。
http://blog.to.it介绍
http://blog.to.it是一个Blog聚合网站,用途,,恩,个人用来分发Blog内容。
使用非常简单,设置一个Blog的rss地址到blog.to.it(PS:可以绑定twitter帐号),然后呢,在你自己的Blog更新日志就行了,blog.to.it会自动读取rss,直接更新。
哈哈,不跟xiaonei那么麻烦,每次还要发个消息给你的信箱,让你选择导入的日志。
是在一次闲逛Drupal.org的时候发现这个网站的,当时就注册了一个帐号,才发现这是个新网站,刚开张不久哈,我的用户编号是120……
对了,Blog to it是用Drupal做的,对于具体实现过程有兴趣的可以参考这篇文章:Blog to it - The social blog directory
我的blog.to.it地址:http://blog.to.it/k5angle
Drupal.org redesign code sprints — donate now
Drupal.org最近在redesign,so they need some money~这次的募捐是$15,000,似乎也不是很多。
唉,非盈利组织都是这样来钱的么,好恐怖。
关于clicki
要说clicki是个什么东西,我也不知道具体该怎么说。
Street13右侧底下那个就是了,其主要功能很简单,就是用来显示访问者信息的。
包括访问者来源,操作系统,ip对应的地址,以及浏览器类型和访问时间。
而具体的数据是存放在clicki的服务器中,另外,clicki也提供了访问信息统计的功能。
恩,早在第1次见到clicki这个东西我就在Street13放了一个,不过后来皮肤更换的时候去掉了,呵呵,老实讲,我嫌js加载的慢。
所以看现在clicki的统计,上次的时间是108天前的=。=
去作者的论坛看了下,似乎这个东西开始的时候是asp做的小工具,当时可能仅仅是模仿老外的一个类似功能吧,
后来用的人多起来了,就重新用php做了下~
而似乎用的最多就是WP用户,哈,国内使用WP当blog程序的人好多唉
