“php perl ruby”目录存档

ruby watir安装

2009年12月26日,星期六

照官方网站上说的安装[http://watir.com/installation/#win],老是在运行

gem update --system
gem install watir

的时候出错,错误如下:

C:\ruby\bin>gem update –system
Updating RubyGems…
Attempting remote update of rubygems-update
Install required dependency builder? [Yn]  Y
ERROR:  While executing gem … (Gem::GemNotFoundException)
    Could not find builder (>= 0) in any repository
(全文…)

discuz Access denied

2009年11月23日,星期一

由于在把PHP 版本的discuz从7.0升级到7.2中忘记了备份config.inc.php而直接覆盖掉了原来的,升级完了之后出现了Access denied的问题,经过查找,发现了解决方法:

把ucenter目录的下的config.php里的UC_XXX配置部分复制到config.inc.php里,然后刷新就可以了。

原因可能是UC配置部分是程序在安装的时候自动生成的,但我却用最原始的配置文件覆盖了。

我复制内容如下:

//应用的UCenter配置信息(可以到UCenter后台->应用管理->查看本应用->复制里面对应的配置信息进行替换)
define(‘UC_CONNECT’, ‘mysql’); // 连接 UCenter 的方式: mysql/NULL, 默认为空时为 fscoketopen(), mysql 是直接连接的数据库, 为了效率, 建议采用 mysql
define(‘UC_DBHOST’, ‘localhost’); // UCenter 数据库主机
define(‘UC_DBUSER’, xxx); // UCenter 数据库用户名
define(‘UC_DBPW’, xxx); // UCenter 数据库密码
define(‘UC_DBNAME’, xx); // UCenter 数据库名称
define(‘UC_DBCHARSET’, ‘gbk’); // UCenter 数据库字符集
define(‘UC_DBTABLEPRE’, ‘`xxx`.uc_’); // UCenter 数据库表前缀
define(‘UC_DBCONNECT’, ’0′); // UCenter 数据库持久连接 0=关闭, 1=打开
define(‘UC_KEY’, xxxxxxxxxxxxxxxxxxxxx); // 与 UCenter 的通信密钥, 要与 UCenter 保持一致
define(‘UC_API’, http://www.iq-works.cn // UCenter 的 URL 地址, 在调用头像时依赖此常量
define(‘UC_CHARSET’, ‘gbk’); // UCenter 的字符集
define(‘UC_IP’, xx.xx.xx.xx); // UCenter 的 IP, 当 UC_CONNECT 为非 mysql 方式时, 并且当前应用服务器解析域名有问题时, 请设置此值
define(‘UC_APPID’, ’1′); // 当前应用的 ID
define(‘UC_PPP’, 20);

编绎gd-2.0.35出错

2009年09月23日,星期三

 

$./configure
$./make

用上面的命令出现了下面的错误:

configure.ac:64: error: possibly undefined macro: AM_ICONV

      If this token and others are legitimate, please use m4_pattern_allow.

      See the Autoconf documentation.

make: *** [configure] Error 1

解决方法, 用下面的命令:

./configure --enable-m4_pattern_allow
./make

Useful PHP Command line options

2009年09月22日,星期二

 

Usage: php [options] [-f] <file> [--] [args...]
       php [options] -r <code> [--] [args...]
       php [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...]
       php [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...]
       php [options] -- [args...]
       php [options] -a

  -a               Run interactively
  -c <path>|<file> Look for php.ini file in this directory
  -n               No php.ini file will be used
  -d foo[=bar]     Define INI entry foo with value 'bar'
  -e               Generate extended information for debugger/profiler
  -f <file>        Parse and execute <file>.
  -h               This help
  -i               PHP information
  -l               Syntax check only (lint)
  -m               Show compiled in modules
  -r <code>        Run PHP <code> without using script tags <?..?>
  -B <begin_code>  Run PHP <begin_code> before processing input lines
  -R <code>        Run PHP <code> for every input line
  -F <file>        Parse and execute <file> for every input line
  -E <end_code>    Run PHP <end_code> after processing all input lines
  -H               Hide any passed arguments from external tools.
  -s               Display colour syntax highlighted source.
  -v               Version number
  -w               Display source with stripped comments and whitespace.
  -z <file>        Load Zend extension <file>.

  args...          Arguments passed to script. Use -- args when first argument
                   starts with - or script is read from stdin

  --ini            Show configuration file names

  --rf <name>      Show information about function <name>.
  --rc <name>      Show information about class <name>.
  --re <name>      Show information about extension <name>.
  --ri <name>      Show configuration for extension <name>.
Detail Usage:
  • Telling PHP to execute a certain file
$ php my_script.php

$ php -f my_script.php
  • Pass the PHP code to execute directly on the command line
$ php -r 'print_r(get_defined_constants());'
  • prints out the built in (and loaded) PHP and Zend modules
  • $ php -m
    [PHP Modules]
    xml
    tokenizer
    standard
    session
    posix
    pcre
    overload
    mysql
    mbstring
    ctype

对cakephp的几点疑惑和误解

2009年09月1日,星期二

由于开始对cakephp还不是很熟悉,所以在学的时候,对cakephp有了些疑惑和误解,现在终于明白了,现在列举如下:

1. cakephp通过Elements对view实现了模块化,使得代码得到了更好的重用,而且Elements还支持cache功能,一开始我认为Element(view)只能通过controller assign变量来动态显示信息,如果这样的话,那cache功能就没用了,因为不管Element有没有cache存在,controller都有要取得数据,然后assign到Element(view)里,其实不是这样的,Element(view)还可以通过requestAction方法取得数据。它的使用方式是:

controller 代码:

// controllers/comments_controller.php
class CommentsController extends AppController {
    function latest() {
        return $this->Comment->find('all', array('order' => 'Comment.created DESC', 'limit' => 10));
    }
}
 
element 代码
 
// views/elements/latest_comments.ctp
 
$comments = $this->requestAction('/comments/latest');
foreach($comments as $comment) {
    echo $comment['Comment']['title'];
}
 
调用方式:
echo $this->element('latest_comments'); 
或支持cache方式
echo $this->element('latest_comments', array('cache'=>'+1 hour')); 
 

根据官方网站的说明,这种方式如果不使用cache的话,它的效率是很差的

2.     cakephp里的controller的继承结构是这样的:xxxController extends AppController extends Controller, Controller是cakephp框架的,AppController默认是空的类,它是让程序员来自由扩展的, xxxController是页面级别的控制逻辑的,但我一开始发现AppController的类文件app_controller.php在cake/libs/controller目录下,我想既然是让程序员自由扩展的,为什么还要放在cake的libs下呢, 那万一应用程序要升级cakephp的版本,如果没有备份的话,那岂不是把之前扩展的内容都给覆盖了啊,其实不是这样的,你需要做的是在/app/目录下建立一个app_controller.php文件就行了, 更简单的方式就是从/cake/libs/controller把app_controller.php复制到/app目录下, 然后在/app目录下的app_controller.php里进行相应的扩展, 这样的如果升级cakephp就不用担心被覆盖了。