Posts Tagged ‘Plug-ins’

Wordpress代码插件

Thursday, October 30th, 2008

很早就想安装一款代码插件,在网上的推荐中,找到了coolcode,coolcode? 显然不是我想要的。不能通过xhtml验证,这点我不看重。界面太丑,当然,你可以自行定义。最不能接受,用的是自定义标签。要是我数据升级,或者我不想用此插件了。那就乱了。 今天又在网上寻索一番,找到了wp-syntax

不喜欢框框和行号把CSS稍作修改,有如下样式。

.wp_syntax {
  color: #100;
  background-color: #fff;
  border: 0px solid silver;
  margin: 0 0 1.5em 0;
  overflow: auto;
}

后台看不到显示效果,所以在这里发一段PHP代码

$hostname = $_SERVER['HTTP_HOST'];
switch ($hostname) {
case "xxlog.com":
    $db = "db1";
    break;
case "test.xxlog.com":
    $db = "db2";
    break;
}
 
// ** MySQL settings ** //
define('DB_NAME', $db);    // The name of the database

久违了,Firefox!

Saturday, July 21st, 2007

说实话,几个月前我并不喜欢firefox, 那时我爱的是maxthon,因为maxthon多标签浏览,强大的手势和拖曳功能,极方便的清理上网痕迹功能,出色的viewpage查看源页源码功能,最重要的是她采用的是IE的芯。
不过,前天重装系统后,我便没再装上maxthon 1.*了,因为firefox对美味书签的支持更友好,几年前,firefox还很不被我赏识,用firefox1.5装上插件同样可以获得maxthon的效果,但是不低于maxthon的CPU、内存占用,国内基于IE制作的网页访问时出现的错位,对于在线多媒体的极度不友好,一点都快不起来的速度…… 在2.0出现之后,加之国内应用群的扩大与许多优秀扩展开发者的出现,firefox也开始完美起来。
重装系统之后,第一件是下载firefox(各大下载网站都有下载 ,我一般去霏凡), 再去把del.icio.us插件装上,把服务器上的书签下载本地,其它的firefox插件全部都存在书签里面。

  1. IE Tab (毕竟国内网站不是所有的都完全支持firefox,比如网银)
  2. Adblock_Plus(网站放广告天经地意,影响阅读就该打PP了)
  3. Fasterfox(Firefox 性能和网络优化)
  4. Gladder(在线网络代理服务器,性能速度都不错)
  5. Super DragAndGo (拖曳功能,好的东西,总是不会被忘记)
  6. Mediawrap(让Firefox 也能够像 IE 一样正常播媒体文件)
  7. Tab Mix Lite CE (加强firefox标签浏览功能,比如双击关闭标签)

装了上面七个插件,访问网站也得心应手了。我终究是个挑剔的人,也写几点不足。

  1. 目前为止还没有发现好的firefox boss key 功能。有boss,肯定要有boss key 。minimize to tray 还算上真正的boss key,期待强人开发。
  2. 暂时还没找到类似maxthon的ViewPage插件,昨天装了一个Web Developer,乖乖~!真的很强大,可是不适合我用,请大家帮着推荐一个。
  3. 某年某月,毕勤同志和我说,firebug很不错。http://addons.mozine.cn/firefox/531/

Firefox + Del.icio.us ,让我不再为收藏夹而苦恼。

Saturday, July 21st, 2007

我曾经一直很疑惑,为什么老外要用 del.icio.us 这长而难记的米来做书签网站,这不符合网站推广的原则。有一天解惑了。 del.icio.us - . . = delicious 能想出这样的米,没点创意还真不行的。
喜欢在网上拼命翻资料的我一族,最要命是千辛万苦找来的东西不见了。上网地点不固定,定期重装系统,偶而忘了倒出maxthon书签,切换到ubuntu……。美味书签,此刻真的美味。
美味书签的插件对于maxthon1/2的支持都不够理想,而ie6/7烂掉我也不会用。选中firefox,进化到2.0,功能多少强点。装上 delicious for firefox extensionnew 一切按步就班。对于美味书签的tag功能并不太感冒,但是那种不管换到那台电脑,只要装上插件就可以找会自己所有的收藏,对于老是弄掉收藏夹的我,真是太宝贵了。稍稍觉得不爽的是,点击书签页,是在当前tab打开新页面,等待高手解决。

discuz 生成缩络图的函数代码

Tuesday, October 3rd, 2006

<?php
define(”op_to_file”, 1); // output to file
define(”op_output”, 2); // output to browser
define(”op_not_keep_scale”, 4); // free scale
define(”op_best_resize_width”, 8); // scale to width
define(”op_best_resize_height”, 16); // scale to height
define(”cm_default”,0); // clipping method: default
define(”cm_left_or_top”,1); // clipping method: left or top
define(”cm_middle”,2); // clipping method: middle
define(”cm_right_or_bottom”,3); // clipping method: right or bottom
/**
* vxresize
*
* @param string $srcfile source file
* @param string $srcfile destination file
* @param int $dstw width of destination file (pixel)
* @param int $dsth height of destination file (pixel)
* @param int $option options, you add multiple options like 1+2(or 1|2), this utilize function 1 & 2
* 1: default,output to file 2: output to browser stream 4: free scale
* 8:scale to width 16:scale to height
* @param int $cutmode clipping method 0: default 1: left or top 2: middle 3: right or bottom
* @param int $startx start x axis (pixel)
* @param int $starty start y axis (pixel)
* @return array return[0]=0: ok; return[0] error code return[1] string: error description
*/function vxresize($srcfile, $dstfile) {
$option=op_to_file ;
$cutmode=cm_left_or_top ;
$dstw=22; //输出文件宽
$dsth=22; //输出文件高
$startx=0;
$starty=0;
$img_type = array(1=>”gif”, 2=>”jpeg”, 3=>”png”);
$type_idx = array(”gif”=>1, “jpg”=>2, “jpeg”=>2, “jpe”=>2, “png”=>3);if (!file_exists($srcfile)) {
return array(-1, “source file not exists: $srcfile.”);
}$path_parts = @pathinfo($dstfile);
$ext = strtolower ($path_parts["extension"]);
if ($ext == “”) {
return array(-5, “can’t detect output image’s type.”);
}
$func_output = “image” . $img_type[$type_idx[$ext]];
if (!function_exists ($func_output)) {
return array(-2, “function not exists for output:$func_output.”);
}
$data = @getimagesize($srcfile);
$func_create = “imagecreatefrom” . $img_type[$data[2]];
if (!function_exists ($func_create)) {
return array(-3, “function not exists for create:$func_create.”);
}
$im = @$func_create($srcfile);
$srcw = @imagesx($im);
$srch = @imagesy($im);
$srcx = 0;
$srcy = 0;
$dstx = 0;
$dsty = 0;
if ($option & op_best_resize_width) {
$dsth = round($dstw * $srch / $srcw);
}
if ($option & op_best_resize_height) {
$dstw = round($dsth * $srcw / $srch);
}
$fdstw = $dstw;
$fdsth = $dsth;
if ($cutmode != cm_default) { // clipping method 1: left or top 2: middle 3: right or bottom
$srcw -= $startx;
$srch -= $starty;
if ($srcw*$dsth > $srch*$dstw) {
$testw = round($dstw * $srch / $dsth);
$testh = $srch;
} else {
$testh = round($dsth * $srcw / $dstw);
$testw = $srcw;
}
switch ($cutmode) {
case cm_left_or_top: $srcx = 0; $srcy = 0; break;
case cm_middle: $srcx = round(($srcw - $testw) / 2);
$srcy = round(($srch - $testh) / 2); break;
case cm_right_or_bottom: $srcx = $srcw - $testw;
$srcy = $srch - $testh;
}
$srcw = $testw;
$srch = $testh;
$srcx += $startx;
$srcy += $starty;
} else {
if (!($option & op_not_keep_scale)) {
if ($srcw*$dsth>$srch*$dstw) {
$fdsth=round($srch*$dstw/$srcw);
$dsty=floor(($dsth-$fdsth)/2);
$fdstw=$dstw;
} else {
$fdstw=round($srcw*$dsth/$srch);
$dstx=floor(($dstw-$fdstw)/2);
$fdsth=$dsth;
}
$dstx=($dstx<0)?0:$dstx;
$dsty=($dstx<0)?0:$dsty;
$dstx=($dstx>($dstw/2))?floor($dstw/2):$dstx;
$dsty=($dsty>($dsth/2))?floor($dsth/s):$dsty;
}
}
if( function_exists(”imagecopyresampled”) and
function_exists(”imagecreatetruecolor”) ){
$func_create = “imagecreatetruecolor”
$func_resize = “imagecopyresampled”
} else {
$func_create = “imagecreate”
$func_resize = “imagecopyresized”
}
$newim = @$func_create($dstw,$dsth);
$black = @imagecolorallocate($newim, 0,0,0);
$back = @imagecolortransparent($newim, $black);
@imagefilledrectangle($newim,0,0,$dstw,$dsth,$black);
@$func_resize($newim,$im,$dstx,$dsty,$srcx,$srcy,$fdstw,$fdsth,$srcw,$srch);
if ($option & op_to_file) {
switch ($type_idx[$ext]) {
case 1:
case 3:
@$func_output($newim,$dstfile);
break;
case 2:
@$func_output($newim,$dstfile,100);
break;
}
}
if ($option & op_output) {
if (function_exists(”headers_sent”)) {
if (headers_sent()) {
return array(-4, “http already sent, can’t output image to browser.”);
}
}
header(”content-type: image/” . $img_type[$type_idx[$ext]]);
@$func_output($newim);
}
@imagedestroy($im);
@imagedestroy($newim);
return array(0, “ok”);
}
?>

Discuz显示作者略缩头像的插件

Sunday, October 1st, 2006

第一次写discuz的插件。原来的插件在forumdisplay调用了头像,但是按一个头像20k来算,一页列表有30个主题,打开此页面需要加载600+,这样的插件没几个人敢装了。修改的文件:

memcp.php
forumdisplay.php
forumdisplay.html

新增一个
avatar_s.inc.php

函数来生成略缩图文件。参考了v2ex.com和日光海岸的代码,于是有了在DZ发的两篇帖子,对于不怎么搞这种东西的人来说,真的很累,每个函数都是翻手册,每个代码都要检查。尽管如此,东西还是很粗糙。
下面是在DZ的两篇帖子的地址,一个是FOR DZ5.0 一个是FOR DZ5.5
http://www.discuz.net/thread-417255-1-1.html for DZ5.0
http://www.discuz.net/thread-583064-1-1.html for DZ5.5