Do not throw exception in exception_handler function and __destruct without try-catch

Do NOT throw exception in exception_handler function, if you do it like below, the error “Fatal error: Exception thrown without a stack frame in Unknown on line 0” will occur set_exception_handler(‘handle_exception’); function handle_exception($e) { throw new Exception(‘throwed in handle_exception’); } throw new Exception(‘error occur’); if you try-catch the Exception in exception_handler function, it will be … Read more

ruby版本的discuz自动注册机

概要:
为了让别人以为你discuz网站的注册用户比较多,你可能需要注册大量虚假用户来伪造discuz网站的人气,如果手动地注册,那效率肯定会很低,势必需要一个工具来帮我们自动化地完成这个工作,本人就用ruby写了这样一个自动为discuz注册用户的工具.

Read more

ruby watir安装

照官方网站上说的安装[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

Read more

discuz Access denied

由于在把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 … Read more

编绎gd-2.0.35出错

  $./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

  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 … Read more

对cakephp的几点疑惑和误解

由于开始对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.     … Read more

perl写cgi之helloworld

用perl写cgi和c/c++写cgi差不多,请参照我的上一篇文章c/c++写cgi之helloworld 这里只说明了怎么用perl写一个cgi的helloworld程序 创建新文件hello.pl, 内容如下: #!/usr/bin/perl print "Content-type: text/html\r\n\r\n"; print "Hello World!\n"; 用命令chmod 777 hello.pl使hello.pl可执行 copy hello.pl到 cgi-bin目录下 在浏览器里打http://localhost/cgi-bin/hello.pl就可以看到结果了 另外,我发现并不需要在httpd.conf 的 AddHandler cgi-script .cgi后面加 .pl也是可以的。

apache找不到mysql.dll

在windows xp下安装了apache和php, php能够正常工作。但不能用php连接mysql, 查看apache的error.log发现了:PHP Warning: PHP Startup: Unable to load dynamic library ‘C:/software/php-5.2/ext/php_mysql.dll’ – The specified module could not be found.\r\n in Unknown on line 0 赶紧查看配置文件吧:—– php.ini extension_dir = “C:/software/php-5.2/ext/” extension=php_mysql.dll 在C:/software/php-5.2/ext/明明有php_mysql.dll这个文件, 可它就是说找不到这个文件, 好奇怪,只好求助于谷哥吧 终于找到啦: 原来php_mysql.dll依赖于libmysql.dll这个文件, 而libmysql.dll又在C:/software/php-5.2/目录下, 而之前并没有把C:/software/php-5.2/加到环境变量里, 也没有把libmysql.dll放到C:\WINDOWS\system32目录下, 系统根本找不到php_mysql.dll, 所以出镜啦 解决方法: 1. 把libmysql.dll放到C:\WINDOWS\system32下。 2. 把PHP[我的就是:C:/software/php-5.2/]的路径加到环境变量里。 [这个没有测过, 因为本人用第一种方法试了,成功了, 所以就偷懒没试这个了]

perl DBI 事务支持

和其它的语言一样, perl DBI对数据库的操作也支持事务处理, 它的实现方式有两个: 一: 在连接数据库的时候就开始一个事务 $dbh = DBI->connect($dataSource, $user, $passwd, {AutoCommit => 0}); 可以看到在连接的时候设置了AutoCommit为false, 也就是说当你对数据库进行更新操作的时候, 它不会自动地把那些更新直接写到数据库里, 而是要程序通过 $dbh->commit来使数据真正地写到数据库里, 或 $dbh->rollback 来回滚刚才的操作 二:通过$dbh->begin_work()语句来开始一个事务 这种方式就不需要在连接数据库的时候设置AutoCommit = 0了, 本人认为这种方式更好, 可以一次数据库连接进行多次事务操作, 不用每一次事务的开始都去连接一次数据库。 示例代码为: $dbh = DBI->connect($dataSource, $user, $passwd, {RaiseError => 1}); $dbh->begin_work eval { foo(…) # do lots of work here bar(…) # including inserts baz(…) # and … Read more