zz巧用139邮箱短信提醒功能

用过139邮箱的都知道139邮箱有一个"邮件到达通知"服务,而且是免费服务哦(我的最爱哈)。我们如果把邮件到达通知与其他服务整合一下,就可以实现更加实用的功能了。

1.其他邮箱的到达提醒

比如我常用的是Gmail邮箱,那么只要在Gmail中设置转发到我的139邮箱,那么我的Gmail有新邮件到达时收到短信了。另外,还可以在Gmail中创建一个过滤器将指定符合条件(如发件人、收件人、主题和所含字词等)的邮件发送到我的139邮箱,就可以有选择地收到到达提醒了,比如我设置了yo2发送到Gmail的邮件转发给139邮箱,每当有新评论时,我就可以以最快的速度收到提醒了。

至于为什么不直接使用139邮箱,而用Gmail,一是Gmail的强大是139邮箱远不能及的;另外,我可不希望收到的短信是垃圾邮件......

2.监测、收取RSS订阅

用139邮箱注册一个RSS2email邮件订阅服务,如Notifixiousxfruitsfeedmailer(更多服务见RSS2email邮件订阅服务收集),导入想要订阅到RSS,就可以监测和收取新闻、博客等更新了。要注意的是,要想阅读Feed,需要设置短信提醒方式为"长短信直接阅读方式",不过最多只能显示350字。如果你愿意,可以出0.3元每条收取最多2万字的彩信-  -#。另外,如果输出的RSS不是全文输出,可以参考小众软件的《RSS摘要输出轻松全文》使用まるごとRSS,再把生成的Feed导入到RSS2email邮件订阅服务中。对于有邮件订阅的网站,那操作就更方便了。

3. 监测网页更新

利用"Follow That Page"服务,可以监测网页的更新,把更新发送到139邮箱。即使无法上网,也可以实时(每小时更新一次)了解网页的更新了。具体操作可以参考这里。特别适合那些没有RSS输出的网页。

4.获取天气预报

把ical格式的天气预报导入Google日历,设置这个日历的提醒方式为邮件,发送到139邮箱。(PS:更简单的方法--Google日历设置短信提醒;再简单点--Google天气短信提醒


其实139邮箱的短信提醒功能还可以整合其他很多服务。只要你能够把文本信息以邮件形式发送到139邮箱,只要你的想象力足够丰富,那么就能随时随地以短信形式阅读了。

Tags: 139邮箱,短信

基于jquery的随机软键盘

没有做特殊字符的输入,只有数字和字母,可能不太实用

主要是看通达信软件输入密码的键盘每次都可以随机变换,觉得挺好玩的,用JS实现了一下。

主要功能:大小写转换,随机生成软键盘。 基于jquery的随机软键盘

keyboard1.JPG

keyboard2.JPG

keyboard3.JPG

关闭再打开,会重新生成一个随机的软键盘

keyboard4.JPG

Tags: javascript,软键盘

TP工具箱升级为项目管理器

很早就开始搞啊搞,做了一些小功能,比如什么TP项目中支持正则的全文搜索一类的,但是因为都没花时间搞,所以一直拖,搞啊搞的不少代码都不知道搞哪去了。

今天花了点时间把工具箱升级一下,可以当项目管理器使,项目新建与浏览激活后进行管理。Model生成的内容更加详细,给定Model可以选择对应的数据表字段生成自动填充与校验的规则等。

其他的就没啥了,全文搜索就不加了,推荐一个工具,search and replace,相当好使。

查看flash演示请移步至 http://www.yhustc.com/TPToolBox/ 

下载地址 TPToolBox.rar

Tags: thinkphp,工具箱

VISTA的文件内容搜索不照啊

想给BLOG的单篇日志加一个上一篇下一篇的链接,网上搜了一下,可以用wp自己提供的previous_post_link和next_post_link这两个函数,可是链接往哪里加呢?index.php好像是单篇日志跟首页共用的,在某些地方做了判断是单页还是首页。 

php代码
  1. <div class="comments">  
  2. <!--p wp_link_pages();-->  
  3. <!--p comments_popup_link(__('No Comments'), __('1 Comment'), __('% Comments'));-->  
  4. &nbsp;</div> 

comments_popup_link这个函数是首页上用的,显示有几条评论。在单个页面上,该函数不输出任何东西。wp_link_pages函数好像没见到有输出,想查一下是干什么的,用VISTA的搜索在文件内容中查找,居然告诉我没有结果。汗死,就算找不到函数原型,起码在这个模板页面里面是出现了啊,无语。还是百度硬盘搜索和GOOGLE的桌面搜索强大啊。我没有给VISTA的搜索编制索引,不过按理说索引应该是影响查找速度,查找精度方面裸查一次跟用索引查应该差不多啊。估计是VISTA默认没有检索PHP文件的原因。因为我试过TXT文件是可以搜索文件内容的,VISTA可能会把不认识的文件(比如PHP文件)忽略掉,即使它的确是以文本方式存储的。

不管了,跳过这个函数,直接跟WP的源文件吧,一路跟下来,跟到了wp-includes\classes.php,里面有这么一段

php代码
  1. function register_globals() {  
  2.     global $wp_query;  
  3.     // Extract updated query vars back into global namespace.  
  4.     foreach ($wp_query-&gt;query_vars as $key =&gt; $value) {  
  5.         $GLOBALS[$key] = $value;  
  6.     }  
  7.     $GLOBALS['query_string'] = &amp; $this-&gt;query_string;  
  8.     $GLOBALS['posts'] = &amp; $wp_query-&gt;posts;  
  9.     $GLOBALS['post'] = &amp; $wp_query-&gt;post;  
  10.     $GLOBALS['request'] = &amp; $wp_query-&gt;request;  
  11.  
  12.     if ( is_single() || is_page() ) {  
  13.         $GLOBALS['more'] = 1;  
  14.         $GLOBALS['single'] = 1;  
  15.     }  

OK,现在知道了如果是显示单篇日志的话,全有一个$GLOBALS['single'] == 1,自己到模板中想要显示上下篇日志链接的地方加上这么一段就O了,CSS嘛,自己定义吧。我的.floatleft和.floatright只是简单的float:left和float:right

php代码
  1. <!--p if($GLOBALS['single'])-->  
  2. <div class="floatleft"><!--p previous_post_link('« %link')--></div>  
  3. <div class="floatright"><!--p next_post_link('%link »')--></div>  
  4. <!--p endif--> 

 

Tags:

编程中的一些细节问题

昨天有个网友问我thinkphp中的自动验证问题,给他解答了一下,他说按照我的方法不管用。我问他验证函数写在Common.php还是写在Model类中,他说写在Model类中。我就纳闷了,Model对数据进行验证,使用自己的成员函数作为验证函数是理所当然的啊,当然,Common.php中的函数作用域是全局的,放在这里当然也是可以的,为什么放在Model中却不行呢?

把源代码找出来看,恍然大悟

php代码
  1. case 'function':// 使用函数进行验证  
  2.      if(function_exists($val[1]) && !$val[1]($data[$val[0]])) {  
  3.           return false;  
  4.      }  
  5.      break

注意函数的调用方式,决定了它只能放在Common.php中,因为如果作为成员函数调用,必须用$this->来调用。也就是下面这个样子。

php代码
  1. case 'function':// 使用函数进行验证  
  2.     if(function_exists($this->{$val[1]}) && !$this->{$val[1]}($data[$val[0]])) {  
  3.         return false;  
  4.     }  
  5.     break


平时都没关心过这些事情,看来以后对成员变量和成员函数使用,尤其是写C++和JAVA的时候,要养成使用this指针的习惯。

Tags: php

关于wordpress的几个问题

1、如何搬家

wordpress.org.cn汇总了一些BLOG程序搬家到wordpress的方法。我自己写了两个工具,详见这里

2、如何显示中文验证码

首先下载这个中文验证码程序到你的wordpress根目录,然后准备开始改wordpress。

第一,编辑主题的comment.php文件,在website下面加上如下内容(为了大家看得更明白一点,我把website的input也包含进来了,大家用的时候把这一段去掉)

php代码
  1. <input id="url" size="22" name="url" value="&lt;?php echo $comment_author_url; ?&gt;" type="text" />  
  2. <script type="text/javascript">  
  3. <!--  
  4. function fleshVerify() {  
  5.    var timenow = new Date().getTime();  
  6.    document.getElementById("verifyImg").src="/verify.php?ts="+timenow;  
  7. }  
  8. // -->  
  9. </script>  
  10.  
  11. <img id="verifyImg" alt="" onclick="fleshVerify()" src="/verify.php" /> <small>* 点击图片刷新验证码</small>  
  12.  
  13. <input id="verify" size="22" name="verify" type="text" /> <label for="verify"><small>验证码 </small></label> 

第二,编辑wp-comments-post.php文件,$comment_type = '';后面加上以下内容(注意:因为这里面写的中文字符没有使用语言包,所以如果你的wordpress使用utf-8字符集,请在修改wp-comments-post.php后以utf-8编码保存,否则会出现乱码)

php代码
  1. $comment_type = '';  
  2. session_start();  
  3. if(md5($_POST[&quot;verify&quot;]) != $_SESSION[&quot;verify&quot;] &amp;&amp; !$user-&gt;ID )  
  4.     wp_die('错误: 你填写的确证码不正确!'); 

Tags:

zz How to implement COMET with PHP

今天在群里遇到一个人,说到web方面的server push的功能。当时无法理解,搜了搜资料。贴过来给大家看看。原贴里面图片连接失效了,我搜了一个,不知道是不是这个图。

Comet is a programming technique that enables web servers to send data to the client without having any need for the client to request it. This technique will produce more responsive applications than classic AJAX. In classic AJAX applications, web browser (client) cannot be notified in real time that the server data model has changed. The user must create a request (for example by clicking on a link) or a periodic AJAX request must happen in order to get new data fro the server.

I will now explain how to implement Comet with PHP programming language. I will demonstrate it on two demos which uses two techniques: the first one is based on hidden <iframe> and the second one is based on classic AJAX non-returning request. The first demo will simply show the server date in realtime on the clients and the second demo will display a mini-chat. 

Comet with iframe technique : server timestamp demo

We need:

  • A PHP script that will handle the persistent http request (backend.php)
     
  • A HTML file that will load Javascript code and that will show the data coming from the server (index.html)
     
  • The prototype library that will help us to write simple JS code
     

To understand how it works this schema should help:

How COMET works

The backend script (PHP)

This script will do an infinite loop and will return the server time as long as the client is connected. Call it backend.php:

php代码
  1. <?php  
  2. header("Cache-Control: no-cache, must-revalidate");  
  3. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");  
  4. flush();  
  5. ?>  
  6. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">  
  7. <html xmlns="http://www.w3.org/1999/xhtml">  
  8. <head>  
  9.   <title>Comet php backend</title>  
  10.   <meta http-equiv="Content-Type" content="text/html; charset=utf-8"  />  
  11. </head>  
  12. <body>  
  13.  
  14. <script type="text/javascript">  
  15.   // KHTML browser don't share javascripts between iframes  
  16.   var is_khtml = navigator.appName.match("Konqueror") || navigator.appVersion.match("KHTML");  
  17.   if (is_khtml)  
  18.   {  
  19.     var prototypejs = document.createElement('script');  
  20.     prototypejs.setAttribute('type','text/javascript');  
  21.     prototypejs.setAttribute('src','prototype.js');  
  22.     var head = document.getElementsByTagName('head');  
  23.     head[0].appendChild(prototypejs);  
  24.   }  
  25.   // load the comet object  
  26.   var comet = window.parent.comet;  
  27. </script>  
  28.  
  29. <?php  
  30. while(1) {  
  31.   echo '<script type="text/javascript">';  
  32.   echo 'comet.printServerTime('.time().');';  
  33.   echo '</script>';  
  34.   flush(); // used to send the echoed data to the client  
  35.   sleep(1); // a little break to unload the server CPU  
  36. }  
  37. ?>  
  38. </body>  
  39. </html> 

The client script (HTML)

This HTML document first load the prototype library in the tag, then it create the tag that will contains the server timer , and finally it create a comet javascript object that will connect the backend script to the time container tag.

The comet object will create some invisible iframe tags (depends on the web browser). These iframes are in charge to create the background persistent http connection with the backend script. Notice: this script do not handle possible connection problems between client and server.

xhtml代码
  1. <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> 
  2. <script type="text/javascript" src="prototype.js"></script> 
  3. <div id="content">The server time will be shown here</div> 
  4. <script type="text/javascript"> 
  5. var comet = {  
  6.   connection   : false,  
  7.   iframediv    : false,  
  8.  
  9.   initialize: function() {  
  10.     if (navigator.appVersion.indexOf("MSIE") != -1) {  
  11.  
  12.       // For IE browsers  
  13.       comet.connection = new ActiveXObject("htmlfile");  
  14.       comet.connection.open();  
  15.       comet.connection.write("<html>");  
  16.       comet.connection.write("<script>document.domain = '"+document.domain+"'");  
  17.       comet.connection.write("</html>");  
  18.       comet.connection.close();  
  19.       cometcomet.iframediv = comet.connection.createElement("div");  
  20.       comet.connection.appendChild(comet.iframediv);  
  21.       cometcomet.connection.parentWindow.comet = comet;  
  22.       comet.iframediv.innerHTML = "<iframe id='comet_iframe' src='./backend.php'></iframe>";  
  23.  
  24.     } else if (navigator.appVersion.indexOf("KHTML") != -1) {  
  25.  
  26.       // for KHTML browsers  
  27.       comet.connection = document.createElement('iframe');  
  28.       comet.connection.setAttribute('id',     'comet_iframe');  
  29.       comet.connection.setAttribute('src',    './backend.php');  
  30.       with (comet.connection.style) {  
  31.         position   = "absolute";  
  32.         left       = top   = "-100px";  
  33.         height     = width = "1px";  
  34.         visibility = "hidden";  
  35.       }  
  36.       document.body.appendChild(comet.connection);  
  37.  
  38.     } else {  
  39.       
  40.       // For other browser (Firefox...)  
  41.       comet.connection = document.createElement('iframe');  
  42.       comet.connection.setAttribute('id',     'comet_iframe');  
  43.       with (comet.connection.style) {  
  44.         left       = top   = "-100px";  
  45.         height     = width = "1px";  
  46.         visibility = "hidden";  
  47.         display    = 'none';  
  48.       }  
  49.       comet.iframediv = document.createElement('iframe');  
  50.       comet.iframediv.setAttribute('src', './backend.php');  
  51.       comet.connection.appendChild(comet.iframediv);  
  52.       document.body.appendChild(comet.connection);  
  53.  
  54.     }  
  55.   },  
  56.  
  57.   // this function will be called from backend.php    
  58.   printServerTime: function (time) {  
  59.     $('content').innerHTML = time;  
  60.   },  
  61.  
  62.   onUnload: function() {  
  63.     if (comet.connection) {  
  64.       comet.connection = false; // release the iframe to prevent problems with IE when reloading the page  
  65.     }  
  66.   }  
  67. }  
  68. Event.observe(window, "load",   comet.initialize);  
  69. Event.observe(window, "unload", comet.onUnload);  
  70. </script> 

 

Download it

Here is the tar.gz archive of this demo.

Online demo

Here is the online demo.
From: http://kerphi.zeitoun.net/articles/comet_and_php/

 

 

Tags:

DOM的一些操作

javascript代码
  1. <script type="text/javascript">  
  2. <!--  
  3. //创建form  
  4. var _form=document.createElement('form');  
  5. _form.setAttribute('name','myform');  
  6. _form.setAttribute('action','');  
  7. _form.setAttribute('method','post');  
  8.  
  9. //创建表  
  10. var _table=document.createElement('table');  
  11. _table.setAttribute('border''1');  
  12. _table.setAttribute('borderColor''red');  
  13. _table.setAttribute('width''300');  
  14. _table.setAttribute('height''100');  
  15.  
  16. //创建一行  
  17. var _tr=_table.insertRow(_table.rows.length);  
  18. // _tr.rowIndex //当前行的行号  
  19.  
  20. //创建一列  
  21. var _td=_tr.insertCell(_tr.cells.length);  
  22.  
  23. //给<td>添加文本  
  24. _txt=document.createTextNode('Intitul');  
  25. _td.appendChild(_txt);  
  26. alert(_td.contentEditable=true);  
  27.  
  28. //创建一个checkbox  
  29. var _input=document.createElement('input');  
  30. _input.setAttribute('type''checkbox');  
  31. _input.setAttribute('name''mycheck');  
  32. _input.setAttribute('value''ddddd');  
  33. _td.appendChild(_input);  
  34. _input.defaultChecked=true;  
  35.  
  36. //创建一个radio  
  37. var _input=document.createElement('input');  
  38. _input.setAttribute('type''radio');  
  39. _input.setAttribute('name''myradio');  
  40. _input.setAttribute('value''ddddd');  
  41. _input.defaultChecked=true;  
  42. _td.appendChild(_input);  
  43.  
  44. //给checkbox添加  
  45. var _label=document.createElement('label');  
  46. _label.setAttribute('for', _input);  
  47. _label.appendChild(document.createTextNode('my check label'));  
  48. _td.appendChild(_label);  
  49.  
  50. //创建一个button  
  51. _input=document.createElement('button');  
  52. _input.setAttribute('type''submit');  
  53. _input.setAttribute('name''mysubmit');  
  54. _input.setAttribute('value''my submit');  
  55. _input.setAttribute('size''130');  
  56. _td.appendChild(_input);  
  57.  
  58. //把表格附加到父容器内  
  59. _form.appendChild(_table);  
  60. document.body.appendChild(_form);  
  61. // -->  
  62. </script> 

另外添几个表格的操作

xhtml代码
  1. <form id="testForm" name="testForm"> 
  2.     <!--文本框,用来输入要删除的行的序号-->      
  3.     <input id="rowtodelete" size="2" name="rowtodelete" type="text" maxlength=&quot;2&quot; value="1">   
  4.     <!--通过onclick调用theTable.deleteRow ()来删除行-->      
  5.     <!--其中theTable.rows.length> 0表示存在行-->      
  6.     <input type="button" value="删除行" onclick="if (theTable.rows.length>0)      
  7.     theTable.deleteRow (document.testForm.rowtodelete.value);"> 
  8.       
  9.     <!-- 上面的rowindex可以用$(trid).rowIndex来获得 -->      
  10.     <!--文本框,用来输入要在其后插入的行的序号-->      
  11.     <input id="rowtoinsert" size="2" name="rowtoinsert" type="text" maxlength="2" value="1"> 
  12.       
  13.     <!--通过onclick调用theTable.insertRow()来插入行-->      
  14.     <input type="button" value="插入行" onclick=&quot;theTable.insertRow(document.testForm.rowtoinsert.value);"> 
  15. </form> 
xhtml代码
  1. <form id="testForm" name="testForm"> 
  2.     <!--通过onclick调用theTable.deleteTHead()来删除表头-->      
  3.     <input type="button" onclick="theTable.deleteTHead();" value="删除<thead>" /> 
  4.       
  5.     <!--通过onclick调用theTable.deleteTFoot()来删除脚注-->      
  6.     <input type="button" onclick="theTable.deleteTFoot();" value="删除<tfoot>" /> 
  7.       
  8.     <!--通过onclick调用theTable.deleteCaption()来删除标题-->      
  9.     <input type="button" onclick="theTable.deleteCaption();" value="删除<caption>" /> 
  10. </form> 

Tags: