mp3插放器插件,需要的拿去用吧

2009-06-28

模仿一个runcode插件改写的,wp的插件写起来还是比较简单的。

播放器是用豆瓣的,你要不喜欢可以换成别的,就需要自己改代码了。

调用方法【mp3】xxxxx【/mp3】,全角换成半角的就行了。

代码如下:

<?php
/*
Plugin Name: mp3player
Plugin URI: http://yibin.us/archives/6348
Description: mp3player in a post
Version: 1.0
Author: yibin
Author URI: http://yibin.us
*/

$player = new player();
add_filter('the_content', array(&$player, 'convert'), -500);
unset($player);
class player
{
function __builderplayer($url) {
if(empty($url)) return '';
return sprintf('<p><embed src="http://www.douban.com/swf/player.swf?url=%s&autoplay=0" type="application/x-shockwave-flash" wmode="transparent" allowscriptaccess="always" width="400" height="80" /></p>',$url);
}
function convert($content)
{

$str_pattern = "/\[mp3\](.*?)\[\/mp3\]/i";
$content = preg_replace($str_pattern,$this->__builderplayer('\\1'),$content);
return $content;
}
}
?>

上传到wp的插件目录,然后在后台启用就行了

领导出差后的这几天

2009-06-26

我家领导出差了,去了这几天正值暴热的北京,天气预报说那气温在37度以上,石家庄都报到了40度,我估计北京也差不多那样了,用领导的话来说:成烤乳猪了。

领导不在的这几天,我如实做到了以下几点:

  1. 坚决不做违法乱纪之事,不做不利于国家、人民生命财产安全的事情。
  2. 坚决做一个好居家男人,坚持每天洗澡,睡前决不遗留受忙碌工作之后留下的臭汗味。
  3. 一如既往地同蚊子蟑螂作斗争,这二天共杀死蚊虫40只以上,剿灭蟑螂5只,战果累累。
  4. 坚决不乱花一分钱。掌握着家里经济命脉的你,出差前给我留了200RMB,加我自己的240RMB,共计440元,到今天为止,钱包里还有410.5元,真正做到了非不得已情况之下不打车上班,坚持骑二轮车,不仅环保还可以健身。
  5. 做到了不饿肚子、不进行少量绝食的行为。晚上买个3-4块钱的小菜或鸡蛋煮面,又营养又健康。
  6. 坚决等你一同看《变形金刚2》,即使明天周末,我也决不会一个人偷着乐。
  7. 坚决在工作上不来半点马虎,高效地完成公司领导分配的任务。

明天老老实实在家做家务,以崭新的姿态迎接若干天后领导的归来!

为表达思念之情,特献上一小曲

Gmail被水产了?

2009-06-25

昨天发现就无法访问Gmail,我对外的联系都是用Gmail。

早上发现依然无法访问,CnBeta上各个地区也有人反映无法登录

http://www.cnbeta.com/articles/87295.htm

ScreenShot00023

现在我们真的是只能在CN局域网里畅游了。

为我们伟大的大中华局域网而欢呼,为日夜奋战在大中华局域网的将士们致以最崇高的鄙视!

我承认我在DZ上有RPWT

2009-06-22

操作cdb_sessions表,发现大量的locked,直接后果就是mysql无法响应WEB的请求,WEB无法响应浏览器端的请求。

ScreenShot00019

ScreenShot00020

太壮观:

+-------+------+-----------+--------+---------+------+--------+------------------------------------------------------------------------------------------------------+
| Id    | User | Host      | db     | Command | Time | State  | Info                                                                                                 |
+-------+------+-----------+--------+---------+------+--------+------------------------------------------------------------------------------------------------------+
| 84082 | root | localhost | discuz | Query   |   54 | update | INSERT INTO  cdb_sessions (sid, ip1, ip2, ip3, ip4, uid, username, groupid, styleid, invisible, acti |
| 84083 | root | localhost | discuz | Query   |   54 | Locked | DELETE FROM  cdb_sessions WHERE sid='Z71z19' OR lastactivity<(1245657270-900) OR ('0'<>'0' AND uid=' |
| 84084 | root | localhost | discuz | Query   |   54 | Locked | SELECT uid, username, groupid, invisible, action, lastactivity, fid FROM cdb_sessions WHERE uid <> 0 |
| 84086 | root | localhost | discuz | Query   |   54 | Locked | SELECT uid, username, groupid, invisible, action, lastactivity, fid FROM cdb_sessions WHERE uid <> 0 |
| 84085 | root | localhost | discuz | Query   |   54 | Locked | SELECT uid, username, groupid, invisible, action, lastactivity, fid FROM cdb_sessions WHERE uid <> 0 |
| 84087 | root | localhost | discuz | Query   |   54 | Locked | SELECT uid, username, groupid, invisible, action, lastactivity, fid FROM cdb_sessions WHERE uid <> 0 |
| 84088 | root | localhost | discuz | Query   |   54 | Locked | SELECT uid, username, groupid, invisible, action, lastactivity, fid FROM cdb_sessions WHERE uid <> 0 |
| 84089 | root | localhost | discuz | Query   |   54 | Locked | SELECT uid, username, groupid, invisible, action, lastactivity, fid FROM cdb_sessions WHERE uid <> 0 |
| 84090 | root | localhost | discuz | Query   |   54 | Locked | SELECT uid, username, groupid, invisible, action, lastactivity, fid FROM cdb_sessions WHERE uid <> 0 |
| 84091 | root | localhost | discuz | Query   |   54 | Locked | SELECT uid, username, groupid, invisible, action, lastactivity, fid FROM cdb_sessions WHERE uid <> 0 |
| 84092 | root | localhost | discuz | Query   |   54 | Locked | SELECT uid, username, groupid, invisible, action, lastactivity, fid FROM cdb_sessions WHERE uid <> 0 |
| 84093 | root | localhost | discuz | Query   |   54 | Locked | DELETE FROM  cdb_sessions WHERE sid='wsX92s' OR lastactivity<(1245657270-900) OR ('0'<>'0' AND uid=' |
| 84095 | root | localhost | discuz | Query   |   54 | Locked | SELECT uid, username, groupid, invisible, action, lastactivity, fid FROM cdb_sessions WHERE uid <> 0 |
| 84096 | root | localhost | discuz | Query   |   54 | Locked | DELETE FROM  cdb_sessions WHERE sid='Ra5ZqL' OR lastactivity<(1245657270-900) OR ('0'<>'0' AND uid=' |
| 84094 | root | localhost | discuz | Query   |   54 | Locked | SELECT uid, username, groupid, invisible, action, lastactivity, fid FROM cdb_sessions WHERE uid <> 0 |
| 84097 | root | localhost | discuz | Query   |   54 | Locked | SELECT sid, uid AS sessionuid, groupid, groupid='6' AS ipbanned, pageviews AS spageviews, styleid, l |
| 84100 | root | localhost | discuz | Query   |   54 | Locked | SELECT sid, uid AS sessionuid, groupid, groupid='6' AS ipbanned, pageviews AS spageviews, styleid, l |
| 84099 | root | localhost | discuz | Query   |   54 | Locked | SELECT uid, username, groupid, invisible, action, lastactivity, fid FROM cdb_sessions WHERE uid <> 0 |

最为BT的是,这些locked形成之后,必须重启mysql才行

我与IE8无缘?

2009-06-20

本来一直用IE7好好的

下午抽疯下载IE8正式版安装,重启后,打开IE

crash

点击是:

crash

网上也找不到遇到类似错误的案例。

卸载再重装还是如此,算了。。。。。

DZ7在windows下的表现

2009-06-19

Discuz7的性能问题一直没能得到很好的解决,

具体表现为在linux+apache环境下,做压力测试时总是当机,要么是mysql show processlist出现众多locked,致使mysql当机;要么是apache不响应,直接当掉。

昨天配置到linux+nginx中,效果还是一样,囧得要命~~~

linux我不知道怎么玩,只能交由平台运维部门的同事全权处理,所以有关的配置也只是他们最清楚了。

无奈之下,昨天晚上对我机器上的discuz做了压测,结果在10个多小时的持续测试中,未出现一个错误,而且Hits/sec总是保持在650左右。

lr1

并发人数控制如下(出于我机器性能考虑,并发人数不大):

100人浏览首页、50人发帖、50人查看帖子列表,这样的压力持续10小时。

点击看大图

点击看大图

真正兼容.net的php 3DES加解密

2009-06-15

php中3des加密的结果与.Net/java不同的帖子与话题实在是太多了,

我前不久也在倒腾这些,不过今天已经搞定了,完全与.net中的兼容

&lt;?php
class Crypt3Des
{
private $key = &quot;&quot;;
private $iv = &quot;&quot;;
/**
* 构造,传递二个已经进行base64_encode的KEY与IV
*
* @param string $key
* @param string $iv
*/
function __construct ($key, $iv)
{
if (empty($key) || empty($iv)) {
echo 'key and iv is not valid';
exit();
}
$this-&gt;key = $key;
$this-&gt;iv = $iv;
}
/**
*加密
* @param &lt;type&gt; $value
* @return &lt;type&gt;
*/
public function encrypt ($value)
{
$td = mcrypt_module_open(MCRYPT_3DES, '', MCRYPT_MODE_CBC, '');
$iv = base64_decode($this-&gt;iv);
$value = $this-&gt;PaddingPKCS7($value);
$key = base64_decode($this-&gt;key);
mcrypt_generic_init($td, $key, $iv);
$ret = base64_encode(mcrypt_generic($td, $value));
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
return $ret;
}
/**
*解密
* @param &lt;type&gt; $value
* @return &lt;type&gt;
*/
public function decrypt ($value)
{
$td = mcrypt_module_open(MCRYPT_3DES, '', MCRYPT_MODE_CBC, '');
$iv = base64_decode($this-&gt;iv);
$key = base64_decode($this-&gt;key);
mcrypt_generic_init($td, $key, $iv);
$ret = trim(mdecrypt_generic($td, base64_decode($value)));
$ret = $this-&gt;UnPaddingPKCS7($ret);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
return $ret;
}
private function PaddingPKCS7 ($data)
{
$block_size = mcrypt_get_block_size('tripledes', 'cbc');
$padding_char = $block_size - (strlen($data) % $block_size);
$data .= str_repeat(chr($padding_char), $padding_char);
return $data;
}
private function UnPaddingPKCS7 ($text)
{
$pad = ord($text{strlen($text) - 1});
if ($pad &gt; strlen($text)) {
return false;
}
if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) {
return false;
}
return substr($text, 0, - 1 * $pad);
}
}
?&gt;
直接拿去用吧。

魂斗罗的最NB玩法

2009-06-01

啥也不说了,直接看