Blog

  • Change WordPress Table Prefix

    WordPress 安全白皮书里倡议其中一条是采用别人猜不着的数据表前缀。

    想必很多WordPress Blog安装时都是采用默认的数据表前缀”wp_”,那么要让”wp_”迁移到”unguessable_”,要做三部分工作:

    1. 修改表中数据,就WordPress当前版本2.6.5而言,有三处要改
      1. 在表”wp_usermeta”中,”meta_key”字段,把”wp_capabilities” 改为 “unguessable_capabilities”
      2. 在表”wp_usermeta”中,”meta_key”字段,把”wp_user_level” 改为 “unguessable_user_level”
      3. 在表”wp_usermeta”中,”option_name”字段,把”wp_user_roles” 改为 “unguessable_user_roles”
    2. 重命名数据表(RENAME TABLE tbl_name TO new_tbl_name[, tbl_name2 TO new_tbl_name2] …)
    3. 修改wp-config.php,$table_prefix = “wp_” 改成 “unguessable_”

    还不算复杂吧。有个plugin据说能帮你自动迁移表前缀,但我没试过,毕竟表前缀前年改一回,何必依赖一个素不相识的plugin呢?

    顺便说一句,如果不做第一部分工作(修改表中数据),前台能可以工作,但后台会有”You do not have sufficient permissions to access this page.”,这错误提示很容易让人联想到密码的hash变了,是老密码无法使用了吗?其实不是,错误跟密码无关,密码还是那个密码。

  • Apache Option FollowSymLinks

    我终于意识到Apache “Option +FollowSymLinks”对我的重要性了。

    以前对一些程序提供的.htaccess sample中Option +FollowSymLinks一条总是熟视无睹(比如,magento .htaccess就有这么一条),今天发现Option FollowSymLinks对我来说并非可有可无。因为我逐步摸索出的Magento一次安装,多处使用WordPress一次安装,多处使用,都是借助于Linux软连接(symbol link)的强大功能。一旦使用Option -FollowSymLinks,我的一次安装多次使用的方案全部失灵了。

  • Command Line Serves Me The Best

    刚在Godaddy开始使用Dedicated Server时,觉得Godaddy自己开发的Simple Control Panel还不错,所有设置都是在Simple Control Panel里完成。不知从什么时候起觉得Simple Control Panel实在不方便,主要是无法完成批量作业。于是,我慢慢摸索常用任务的命令行方式,或者直接修改配置文件。

    今天凌晨我纯属好奇,想在Simple Control Panel尝试启动Linux防火墙。很早以前我试过启动防火墙,结果是Actinic无法上传文件,其他网站正常。笨笨的Actinic,但没办法,它是一个主要网站,服务器只有为它Compromise。后来有多次升级,所以我突然想看看Actinic能否与防火墙并存。

    可能与平时我直接修改配置文件有关,经我修改的配置文件已经不是Simple Control Panel能看懂的了。我在Simple Control Panel里一点启动防火墙,结果所有的网站都访问不了了,要命的是连Simple Control Panel也访问不了了,我怎么才能关闭防火墙?

    因为不知道学习命令行方式关闭防火墙有多难,情急之下先submit a ticket,请support把眼前的问题解决再说。然后当然不能等support回复啦,我开始Google,发现用ssh command line关闭防火墙很简单,真的,两句话搞掂。早知这么简单,我就不会花5分钟时间submit the ticket。

    我又花了至少两分钟submit another ticket cancelling the request in the previous ticket。

    我喜欢命令行,我喜欢SSH,另外我也喜欢Google。

  • VBA字符串精确比较

    我实在没想到在VBA里,(“abc” = “ABC”) = true。

    为了debug这个被我认为 false的判断,我找了好久。找到了已经想通了,从DOS到Windows,微软不是一直在营造一种大小写不敏感的气氛吗?只是我没估计到从程序员这么严谨的角度,竟然也是忽略字符串大小写。可能我越来越Linux了,对Windows这一套哲学越来越不适应了。

    不过,VBA里要精确比较字符串也是做得到的: StrComp(String1, String2, vbBinaryCompare).

  • qTranslate Update

    我很喜欢qTranslate这个插件,尽管我没在这个blog上使用。

    qTranslate更新很快,最近几次我注意到每次WordPress一有更新,qTranslate随后就有更新。

    但我就不明白了——每次WordPress更新后,老版本的qTranslate就工作不正常了。编辑时,qTranslate is disabled(当然这也不是什么大不了的缺陷,反正我更习惯于直接写代码)。非得qTranslate出一个更新,这个毛病才能解决。

    是不是秦谦老兄写的qTransalte不太符合WordPress Plugin规范?

  • Create Effective Backlinks

    要有好排名得有好的backlinks,这个道理我很早就知道了,但一直未及深入研究。最近读到一篇文章很有可操作性,我准备依样画瓢。

    1. Use wordpress.com for creating your blogs. – WordPress has grate on-site SEO and blogs on WordPress.com get indexed pretty quickly. Once you create an account there, you can create unlimited number of blogs without having to register any new accounts.

      不指是直接使用wordpress.com的blog好,还是自己安装一个wordpress blog好?

    2. Write more then one post per blog. – Google loves backlinks that look natural and active blog that has your link in blogrol seems pretty natural. You can also include some backlinks inside blog posts linking to relevant parts of the website you are building backlinks for.

      到底写几篇post才算好呢?要知道写post很累的啊!

    3. Use Scribefire – Scribefire is grate firefox plugin that will allow you to write into your wordpress blogs from your browser. It helps a lot to have all your blogs listed in it and be able to drag-and-drop pictures from the web directly into your blog posts.

      Scribefire倒不必了,我觉得在线编辑已经很方便了。

    4. Your blog posts don’t have to be masterpieces – Remember you are not writing content for readers, you are writing it for spiders so it only has to seem relevant to the topic.

      这我知道,但我总会尽力写好post的。随便写点东西,或者排版很糟糕,搜索引擎可以糊弄过去,观众糊弄不过去啊。

    5. Promote your blogs – You won’t have much use of these backlinks if you don’t build backlinks for the blog. Luckily, building these backlinks is not so hard as you can use all the benefits provided by RSS feed. Submit your blogs RSS feed to as many services as you can that will create some backlinks out of it. It is also easier to do this when you have more blogs to submit at once.

      我觉得submit rss feed是最值得操作的。

  • PhpList Can Work With SSL POP

    想要phpList process bounce messages,邮箱却只支持SSL POP (port 995, 如gmail)?没问题。

    config.php 作以下设置:

    $bounce_protocol = 'pop';
    $message_envelope = 'username@gmail.com';
    $bounce_mailbox_host = 'pop.gmail.com';
    $bounce_mailbox_user = 'username@gmail.com';
    $bounce_mailbox_password = 'password';
    $bounce_mailbox_port = "995/pop3/ssl/novalidate-cert";

    我本还担心phpList 不能从gmail上pop出bounce messages,正想着去专门建一个未经SSL处理的POP邮箱,没想到phpList轻易就达到了我的要求。

    另外我还发现,按照phpList自己的说法,php必须运行在safe_mode off的环境下才能让phpList 处理bounce messages,但我亲身实验结果显示safe_mode can be on.

  • Magento Cache

    关于Magento的Cache机制还有待进一步了解。目前我知道的是:

    在local.xml更改Magento backend admin url以后,要Refresh Cache才会生效。

    刚才我试了很久才想到要清除缓存,否则我还以为我没找对地方。

  • 老板不了解下属的工作量是种悲哀

    金融危机袭来,公司的业务摇摇欲坠。老板收缩战线,解雇了几个人,暂时认为我比较重要,留下了。我倒没多想,先干着呗。

    但是事情总要有人做啊,老板亲自上阵,做我同事原来做的事情。今天盘点库存,盘点完毕入账的时候,他花了6个小时还没完成老同事2个小时就能完成的收入工作。最后老板感慨,这输入原来要花那么多时间啊。我说,除非你投资一套条码设备,否则这时间能省下来吗?

    老板无语,然后他又开始怀疑老同事是否真能这么快完成输入。我无语,其实我也干过这活,也就2个小时的工作量吧,但这是建立在我熟记产品代码和产品名称的实践经验基础上的。

    我并不是建议老板们都来做做下属的工作(专业分工嘛),但老板如果以为下属的工作都那么好做的话,那是种悲哀——下属的悲哀,更是老板的悲哀。

  • Use Analytics to Track Newsletter Open Rate

    I realise it is NOT possible to use Analytics to track newsletter open rate. Because:

    • To track if an email is opened, you put an invisible image into the email with img src calling a tracking program.
    • If you put a web page url as img src, the javascript of the web page won’t run.

    So, in order to track newsletter open rate, you must point img src to a server-side tracking program. Analytics won’t fit for this job because it is client-side script.

    Actually, tracking newsletter open rate is very easy with phpList, which I have been using for long. Simply to [USERTRACK] into the body of the email.