Js控制输入字符数限制

From: http://www.phpcake.cn/archives/26/

  1. <script type="text/javascript">
  2. function ismaxlength(obj){ 
  3. var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : "" 
  4. if (obj.getAttribute && obj.value.length>mlength) 
  5. obj.value=obj.value.substring(0,mlength) 
  6. } 
  7. </script>
  8.  
  9. <textarea maxlength="10" onkeyup="return ismaxlength(this)"></textarea>
Tags: javascript

ZendFramework 使用数据表前缀

目录结构
zend framework dirs

在 config.ini 定义 prefix

[general]
adapter  = PDO_MYSQL
host     = localhost
username = root
password = 123456
dbname   = test
charset  = utf8
prefix   = pf_    //表前缀

index.php 中将 prefix 注册

  1. // 读取数据库配置
  2. $dbconfig = new Zend_Config_Ini('../config/config.ini', 'general');
  3. // 配置数据库
  4. $database = Zend_Db::factory($dbconfig->adapter,$dbconfig->toArray());
  5. // 设置数据库编码
  6. $database->query("set names {$dbconfig->charset};");
  7. Zend_Db_Table::setDefaultAdapter($database);
  8. Zend_Registry::set('database',$database);
  9. // 数据表前缀
  10. Zend_Registry::set('dbprefix',$dbconfig->prefix);

在 library/Custom 目录下新建文件 Db.php 继承 Zend_Db_Table 类

  1. class Custom_Db extends Zend_Db_Table
  2. {
  3.     public function __construct()
  4.     {
  5.         $dbprefix = Zend_Registry::get('dbprefix');
  6.         $this->_name = $dbprefix.$this->_name;
  7.         parent::__construct();
  8.     }
  9. }

最后在 model 中继承 Custom_Db 即可

  1. class User extends Custom_Db
  2. {
  3.     protected $_name = 'users';     //在Custom_Db中会自动加上表名的前缀
  4.     protected $_primary = 'userid'; //主键
  5. }
Tags: dbprefix, php, zendframework

ZEND studio 编辑器字体美化方法

我这里用的是 ZendStudio 5.5.0
找到这个目录 "Zend\ZendStudio-5.5.0\jre\lib"
除 fontconfig.properties.src 文件保留外,删除所有以 fontconfig. 开头的文件
将 fontconfig.properties.src 文件改名为 fontconfig.properties, 然后打开编辑
把以下的值

dialoginput.plain.alphabetic
dialoginput.bold.alphabetic
dialoginput.italic.alphabetic
dialoginput.bolditalic.alphabetic

改成你要设置的字体名称

这里我设置的是

dialoginput.plain.alphabetic=Lucida Sans Typewriter
dialoginput.plain.chinese-ms950=MsYahei

dialoginput.bold.alphabetic=Lucida Sans Typewriter Bold
dialoginput.bold.chinese-ms950=MsYahei Bold

dialoginput.italic.alphabetic=Lucida Sans Typewriter
dialoginput.italic.chinese-ms950=MsYahei

dialoginput.bolditalic.alphabetic=Lucida Sans Typewriter Bold
dialoginput.bolditalic.chinese-ms950=MsYahei Bold

其中 dialoginput.xxxx.chinese-ms950 是中文所用字体

然后再文件末尾添加定义上面设置的字体名称

filename.MsYahei=MSYH.TTF
filename.MsYahei_Bold=MSYHBD.TTF

filename.Lucida_Sans_Typewriter=LucidaTypewriterRegular.ttf
filename.Lucida_Sans_Typewriter_Bold=LucidaTypewriterBold.ttf

其中如 filename.MsYahei 中的 MsYahei 就是上面 dialoginput.xxxx.chinese-ms950 所使用的中文名称, 这里空格要改成 "_", 后面的 MSYH.TTF 是你系统中安装的字体文件的名称, 打开系统字体文件夹(如c:\windows\fonts), 以详细方式查看, 文件名一列即是

打开 zend studio, 指定编辑器的字体为 "dialoginput",然后重启编辑器即可看到效果

Tags: IDE, zend, zendstudio, 字体

为wordpress添加coolcode插件的quicktag

修改 wp-includes/js/quicktags.js 文件

1. 找到

  1. edButtons[edButtons.length] =
  2. new edButton('ed_code'
  3. ,'code'
  4. ,'<code>'
  5. ,'</code>'
  6. ,'c'
  7. );

在后面添加

  1. edButtons[edButtons.length] =
  2. new edButton('ed_coolcode'
  3. ,'coolcode'
  4. ,''
  5. ,'</coolcode>'
  6. ,'x'
  7. );

2. 找到

  1. else if (button.id == 'ed_link') {
  2.         document.write('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertLink(edCanvas, ' + i + ');" value="' + button.display + '" />');
  3.     }

在后面添加

  1. else if (button.id == 'ed_coolcode') {
  2.         document.write('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertCoolcode(edCanvas, ' + i + ');" value="' + button.display + '" />');
  3.     }

3. 在文件末尾添加

  1. function edInsertCoolcode(myField, i, defaultLang, defaultLine) {
  2.     if (!defaultLang) {
  3.         defaultLang = 'php';
  4.     }
  5.     if (!defaultLine) {
  6.         defaultLine = 'off';
  7.     }
  8.     if (!edCheckOpenTags(i)) {
  9.         var codeLang = prompt('输入需要加亮的程序语言', defaultLang);
  10.         var codeLine = prompt('是否显示行号(on, off)', defaultLine);
  11.         edButtons[i].tagStart = '<' + 'coolcode';
  12.         if (codeLang) {
  13.             edButtons[i].tagStart = edButtons[i].tagStart + ' lang="' 
  14.                                     + codeLang + '"'
  15.         }
  16.         if (codeLine) {
  17.             edButtons[i].tagStart = edButtons[i].tagStart + ' linenum="' 
  18.                                     + codeLine + '"';
  19.         }
  20.         edButtons[i].tagStart = edButtons[i].tagStart + '>';
  21.         edInsertTag(myField, i);
  22.     }
  23.     else {
  24.         edInsertTag(myField, i);
  25.     }
  26. }
Tags: coolcode, plugins, quicktags, wordpress

自动等比例缩放网页中的图片

resizeimg.js

  1. window.onload = function() {
  2.  
  3.     for (var index = 0; index < document.images.length; index++) {
  4.  
  5.         var widthRestriction = 400;
  6.         var heightRestriction = 400;
  7.         var rate = document.images[index].width / document.images[index].height;
  8.  
  9.         if (document.images[index].width > widthRestriction) {
  10.             document.images[index].width = widthRestriction;
  11.             document.images[index].height = widthRestriction / rate;
  12.         } else if (document.images[index].height > heightRestriction) {
  13.             document.images[index].height = heightRestriction;
  14.             document.images[index].width = heightRestriction * rate;
  15.         }
  16.  
  17.         document.images[index].onclick = function() {window.open(this.src)};
  18.         document.images[index].title = document.images[index].title + ' 点击在新窗口中查看原图';
  19.     }
  20. }
Tags: javascript, 图片, 网页设计

vmware server (1.03) sn for linux

Your serial number(s):
9A44N-YAFFA-22J9Q-4J314
9814N-YAY4C-20N45-402AH
9AJFM-Y8ADA-28HC3-4TL8D
981D5-Y0A4V-2AM41-403LN
98N60-Y2FFZ-20JC2-4LQ1X
92J6J-Y8CDZ-200F4-421C0
92HD5-YAV4F-2AJ3P-4TMLX
98JF1-Y2VDZ-22036-4L6TX
9A1DM-YAF6U-20H4M-4A735
98041-Y2UFV-224DH-48QHR
90M6J-Y0U4C-2A5D4-40KHN
98MF1-YAU6C-22561-4A52M
9A16H-Y8ZDA-22MDH-48Q2D
90HD0-Y0Z6V-22H4N-48MUM
9054J-Y2YFV-2A592-4TKHM
98H6H-Y8ZDG-201D1-4042W
90M4J-Y0VDZ-20HFM-4A0HT
90H4H-Y2A4Y-2AMDJ-4A5TJ
90144-Y8U6V-2A112-4L2JJ
98165-Y0C4C-22H44-4AQ38
90H61-YAAFA-20H3L-4T6HX
9816M-Y8C6V-2A5FM-481TT
985DM-Y8GDY-20144-4809X
90M44-Y8AFU-28J36-4LK01
90M4H-Y2UDC-28540-407J9

Tags: linux, sn, vmware