Archive for the 'PHP' Category

SSE_RSS v2.0发布

sse_rss


为了方便大家在各种不能上SSE的情况下关注最新通知,Jerry重写了SSE_RSS。
地址在
http://www.JerryHong.com/SSE_RSS
,欢迎订阅。

1.现在可以直接得到每条通知的具体内容,不用从链接转过去看,更方便手机和用firefox用户(通知页面里的那个Textarea真是让人咬牙切齿口牙)。
2.通知中的附件(若有)链接会附加到具体信息的尾部,即使只看RSS也不会漏掉。
3.优化远程获取机制,一小时更新一次,冗余信息放在数据库里,尽量减少从SSE上获取的次数。

软院通知RSS(附代码)

ponyfish的那个通配符很难设,于是自己用PHP写了一个
两个订阅地址,择一即可:
http://www.JerryHong.com/SSE_RSS/
这个反应比较慢(其实是定位到index.php的),但肯定是最新的
http://www.JerryHong.com/SSE_RSS/index.xml
这个反应很快(xml文件嘛),但要有人访问了上面那个地址这个xml文件才会被更新

改进空间:
1.让index.php也直接返回xml中的内容,而从sse官方获取最新通知的动作由ajax或IFrame来触发,但是rss阅读器应该不会支持这两种……
2.怎么才能统计订阅数?是不是统计每天有阅读活动的读者数量?在统计每天有阅读活动的读者数量时要不要记录IP来判断是不是今天已经阅读过了?
Continue reading '软院通知RSS(附代码)'

Youtube的恐怖统计数据

(引用自GSeeker)

1.YouTube上面一共有超过600万个视频,并且每个月增长20%;
2.YouTube上面所有的视频所占的容量大概是45TB(1TB=1024GB);
3.自从YouTube上线以来,上面的视频被观看的时间总计大概为9305年;
4.YouTube每个月花在视频带宽上的费用高达数百万美元;
5.YouTube上面最热门的视频的标题一般包含"love"、"music"或"girl";

虽然我们的系统暂时不会这样子,但想想怎么解决这些问题也是很有意思的……(当然第5个不算问题- -#)

Wordpress Plugin: SimplePageNavi v1.0 release by Jerry

改变WORDPRESS原本换页方法的插件,效果为显示页码列表而非“上一页 下一页”
安装:不解释
使用:见E文

Change the page navigation way.
Installation: unzip & enable
Usage: open your template, find index.php
search for navigation part like this:

  1. <div class="alignleft"><?php next_posts_link('&laquo; 较旧文章') ?></div>
  2.             <div class="alignright"><?php previous_posts_link('较新文章 &raquo;') ?></div>

Replace it with this:

  1. <?php 
  2.             if(function_exists('SimplePageNavi') )
  3.                 SimplePageNavi();
  4.             else
  5.             {
  6.             ?>
  7.             <div class="alignleft"><?php next_posts_link('&laquo; 较旧文章') ?></div>
  8.             <div class="alignright"><?php previous_posts_link('较新文章 &raquo;') ?></div>
  9.             <?php
  10.             }
  11.             ?>

Quite easy, huh?
Download(299 times)

Wordpress Plugin: Download Counter v1.1 Released by Jerry 下载计数器

简单介绍下吧,此Plugin是基于VanguardDownload Counter v1.0来写的,作用是统计附件的下载次数,并让下载者看到此文件已被载过多少次(DISCUZ!的下载次数总看过吧)
安装过程就不解释了,下面E文里有,还是老样子,有问题请留言或发至hjrgenius (a) 163.com,欢迎讨论:)
这是第三个WP插件了,写完以后对WordPress的敬仰有如滔滔江水连绵不绝又如黄河泛滥一发不可收拾。用Wordpress的架构来只是做BLOG实在是可惜可惜!

Hello everyone, this is the third plugin that I've developed/hacked/enhanced/etc... and I'm supposed to use english to descript it this time:)
Download:
Download(370 times)
Description:
The download counter plugin helps you Count the times a file has been downloaded as well as some misc statistics. It also let downloaders know how many times the file has been downloaded by others.

I enhanced it based on Vanguard's Download Counter v1.0.

Installation:
Unzip the contents of the .zip file. Upload the folder 'DownloadCounter' to: WordPress_directory/wp-content/plugins
Make sure that, inside your plugin folder, there're 3 files: download.php, DownloadCounter.php and functions.inc.php
Go to your administration panel and activate this plugin.

Usage:
The plugin is now installed, all you have to do now is

  • 1.upload files via ftp or else.
  • 2.add files using this plugin's Administration panel.No special code is needed to be placed in any of your theme files. This plugin automatically generates a simple HTML code to use in your files.
  • 3.When you create/edit a post, there will be a button in the panel to let you add tags in the post. All you have to know is the id of the file(which can be got in administration panel of downloadcounter).
  • Then when the post is viewed, the tags will be automatically replaced with download link with the count of downloads.
  • If you have any problems, please leave a comment here or mail to hjrgenius (a) 163.com. Discussion is welcomed.
    Good luck!

    PHP + ADO + ACCESS 类库

    不是我想用ACCESS的,么办法啊,用户即上帝么。
    更何况这上帝不懂数据库啥的……与其劝他换个服务商还不如委屈自己写个类库将就一下。
    网上有ODBC版本,但在我这用有点小小的版本问题……又是让人无奈的上帝。

    贴代码啦,代码晕眩症的就不用点全文链接了。
    Continue reading 'PHP + ADO + ACCESS 类库'

    从百度获取LRC的小程序

    一开始只是想练下javascript,练下ajax的基本功--使用xmlHttpRequest,没想到后来写成了这样一个有点像BOT的程序。
    用这个程序再配合迅雷,我刷个牙的功夫载了445首歌的lrc下来(搜索"安静")!这样的话要建立自己的lrc服务器就方便多了,嘿嘿。
    Download(264 times)

    ieHTTPHeadersSetup 下载

    IE插件,可以看到进出的header消息,能搜到的链接都太慢了,自己放一个吧
    Download(256 times)
    update:推荐大家用IEhttpAnalyzer,功能更全,而且免费

    自制PHP+Javascript自动投票机v1.0

    昨天碰到一个投票页面,可能自己比较闲,可能也是因为这个页面比较弱智吧,一时兴起看看自己能不能写一个PHP自动投票程序来玩玩他们。
    不方便透露页面地址,就说下特征吧,这个页面不要求验证码,但是一段时间(10分钟左右)内反复提交的话它会弹出一个框说一个IP只能投一票。为什么一个IP只能投一票还限定时间呢?我想应该是由于当前的IP分配使很多人挤在一个公网IP下,这样子不太公平,就只好表面上吓唬一下,实际上只是有cooldown设置罢了。

    好了,那么就有两种途径,一个是伪装自己发包的源IP,还有一个是写自动发包程序。前一种还不知怎么做(好象是层不太对),但后一种用一般用来做Ajax的window.XMLHttpRequest可以比较轻松地搞定。

    先用了SpyNet, Ethereal这些经典的抓包程序,明明把目标设为无线网卡Intel(R) PRO/Wireless 3945ABG Network Connection,也设好过滤器了,但一直抓不到包。一怒之下把本本搬到路由器旁插线上网,包源源不断地蹦出来了。。。无语,但用这些软件分析出来的包太复杂,我要的只是head信息,于是去国外网站花两个小时拖了一个IE插件下来,装上去以后可以直接看到IE收发的包,真方便。

    收到包以后就简单了,通过查看包的内容和投票页面的源代码,发现要递交的只是
    POST:sel58=yes&Submit=%CD%B6%C6%B1,
    Get:?action=add&id=5

    连Cookies都没有!更不要说Session了。

    打开EditPlus开始写:

    先个测试的页面,是目标页面的简化版:
    vote.php

    1. <?php
    2. $stra=$_POST['sel58'];
    3. $filename='counter.txt';
    4. if($handle=fopen($filename, 'a'))
    5. {
    6. fwrite($handle, $stra);
    7. }
    8. fclose($handle);
    9. echo $stra;
    10. echo 'done';
    11. ?>

    然后是投票页面,写完后才发现没用到PHP。。。完全是Javascript...
    AutoVote.php

    1. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    2.  
    3. <script type="text/javascript" language="javascript">     var http_request = false;     function makeRequest(url) {         http_request = false;
    4.  
    5. if (window.XMLHttpRequest) { // Mozilla, Safari,...         alert(\'firefox\');             http_request = new XMLHttpRequest();             if (http_request.overrideMimeType) {                 http_request.overrideMimeType(\'text/xml\');             }         } else if (window.ActiveXObject) { // IE         alert(\'ie\');             try {                 http_request = new ActiveXObject("Msxml2.XMLHTTP");             } catch (e) {                 try {                     http_request = new ActiveXObject("Microsoft.XMLHTTP");                 } catch (e) {}             }         }
    6.  
    7. if (!http_request) {             alert(\'Giving up :( Cannot create an XMLHTTP instance\');             return false;         }         //http_request.setHeader("Charset","GB2312");         http_request.onreadystatechange = alertContents;         http_request.open(\'POST\', url, true);         http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");/*这句少了郁闷好久*/         //alert(\'open succeeded\');         http_request.send(\'sel58=yes&amp;Submit=%CD%B6%C6%B1\');         //alert(\'post succeeded\');
    8.  
    9. }
    10.  
    11. function alertContents() {
    12.  
    13. if (http_request.readyState == 4) {             if (http_request.status == 200) {                 alert(http_request.responseText);//这个可以收到返回的Text数据                 //alert(\'连接到服务器\');             } else {                 alert(\'There was a problem with the request.\');             }         }
    14.  
    15. }     window.setInterval("makeRequest(\'vote.php\')", 600000);//10分钟一次!vote.php为目标页面 </script>
    16. <span>
    17. </span>     style="cursor: pointer; text-decoration: underline"
    18. onclick="makeRequest('vote.php')"&amp;gt;
    19. Make a request
    20. ?>

    把两个页面放在Apache的htdos目录下测试,一切OK,把目标页面改为我要投票的对象,然后就等着吧,10分钟弹出个框返回结果。(当然也可以在Apache下面改成1毫秒一次,体验一下手忙脚乱的感觉。。。)

    然后把那个IE窗口最小化,看着票数慢慢地上升。。。

    升。。。
    升。。。
    升。。。
    升。。。
    升。。。
    升。。。
    返回莫名其妙的结果。。。
    返回莫名其妙的结果。。。
    返回莫名其妙的结果。。。

    ??打开那个投票页面看了一下,原来管理员不知什么时候(应该就是刚才)加了一个验证码。。。难不成要跟你斗到底。。。看了一下源代码,只是多了一句:

    1. <script src="authimg.php" language="javascript"></script>

    看了一下那个authimg.php,显示的是

    1. document.write('gndBdh')

    gndBdh应该是随机生成的字串,既然要和投票接收页面配合的话肯定要用session或cookie,看了一下head,果然多了

    1. Set-Cookie: PHPSESSID=dc48aedcd03478a0ee6f13603b37937e; path=/

    模拟一下cookie的话应该可以,不过我想睡觉了。。。SO我去睡觉了,可爱的管理员Byebye...